exam questions

Exam 1z0-808 All Questions

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

Exam 1z0-808 topic 1 question 101 discussion

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

Given the code fragment:

What is the result?

  • A. Compilation fails at both line n1 and line n2.
  • B. Compilation fails only at line n2.
  • C. Compilation fails only at line n1.
  • D. Jesse 25 Walter 52
Show Suggested Answer Hide Answer
Suggested Answer: B 🗳️

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
fvelazqueznava
3 months, 1 week ago
Selected Answer: B
Compilation only fail in the 2nd line, because to call a constructor in the same file, you need to use this()
upvoted 1 times
...
akbiyik
1 year, 1 month ago
Selected Answer: B
Answer is B.
upvoted 1 times
...
eilla
1 year, 1 month ago
Answer is B. Correct syntax for the second constructor to call the first would be to use this(name).
upvoted 3 times
...
carloswork
1 year, 2 months ago
Selected Answer: B
Answer is B. To test: class Person { String name; int age = 25; Person (String name) { // line 1 setName(name); } public Person (String name, int age) { Person(name); // line 2 setAge(age); } // setter and getter methods go here public void setName (String name) { this.name = name; } public void setAge (int age) { this.age = age; } public String show() { return name + " " + age; } } public class Teste { public static void main(String[] args) { Person p1 = new Person("Jesse"); Person p2 = new Person("Walter",52); System.out.println(p1.show()); System.out.println(p2.show()); } }
upvoted 2 times
...
iSnover
1 year, 3 months ago
Selected Answer: B
Correct Answer is B, the line 1 compiles normaly and execute because even though the constructor is not public, the main method is in the same class and can be seen to be instantiated. On line 2, the constructor is wrong because a method is being used inside it.
upvoted 3 times
...
shivkumarx
1 year, 4 months ago
Question is written wrong here, compilation only fails at n2
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