exam questions

Exam 1z0-809 All Questions

View all questions & answers for the 1z0-809 exam

Exam 1z0-809 topic 1 question 22 discussion

Actual exam question from Oracle's 1z0-809
Question #: 22
Topic #: 1
[All 1z0-809 Questions]

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());
Show Suggested Answer Hide Answer
Suggested Answer: A 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
Ritesh_
Highly Voted 4 years, 9 months ago
Answer is A
upvoted 7 times
...
steefaand
Most Recent 5 months, 4 weeks ago
Selected Answer: A
A is correct. C and D don't compile and B reads single char and not whole value of input.
upvoted 1 times
...
duydn
10 months, 2 weeks ago
Selected Answer: A
readLine() not readline()
upvoted 1 times
...
wk8b
1 year, 2 months ago
Answer is B. A is incorrect, in code was used br.readline() not br.readLine so it is incorrect.
upvoted 1 times
...
r1muka5
1 year, 5 months ago
Correct answer is A. Tested.
upvoted 1 times
...
Sofia_Shireen
2 years, 8 months ago
int GDP = Integer.parseInt(br.readLine());
upvoted 2 times
...
Innovation
4 years, 6 months ago
A is correct, tested
upvoted 2 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago