Which code fragment, when inserted at line 1, enables t…

Given the code fragment:
public static void main (String [ ] args) throws IOException {
BufferedReader br = new BufferedReader (new InputStremReader (System.in));
System.out.print (“Enter GDP: “);
//line 1
}
Which code fragment, when inserted at line 1, enables the code to read the GDP from the user?

Given the code fragment:
public static void main (String [ ] args) throws IOException {
BufferedReader br = new BufferedReader (new InputStremReader (System.in));
System.out.print (“Enter GDP: “);
//line 1
}
Which code fragment, when inserted at line 1, enables the code to read the GDP from the user?

A.
int GDP = Integer.parseInt (br.readline());

B.
int GDP = br.read();

C.
int GDP = br.nextInt();

D.
int GDP = Integer.parseInt (br.next());



Leave a Reply 8

Your email address will not be published. Required fields are marked *


smh

smh

B.
int GDP = br.read();
Enter GDP: 5555 BUILD SUCCESSFUL

Deepali Sharma

Deepali Sharma

B IS THE RIGHT ANSWER

Berti John

Berti John

A. is correct

smh

smh

A also correct.

smh

smh

A is correct because you can use only integers for integers.

ara

ara

B.
Answer A causes compiler error – Cannot resolve method ‘readline()’