exam questions

Exam 1z0-808 All Questions

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

Exam 1z0-808 topic 1 question 147 discussion

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

Given:

And given the code fragment:

What is the result?

  • A. Compilation fails at line n2.
  • B. Compilation fails at line n1.
  • C. 20:20
  • D. 10:20
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
MPignaProTech
2 months, 3 weeks ago
Selected Answer: A
Cannot cal a package private constructor with super
upvoted 1 times
...
carloswork
2 years, 2 months ago
Selected Answer: C
Answer is C. To test: class Vehicle { int x; Vehicle() { this(10); // line n1 } Vehicle(int x) { this.x = x; } } class Car extends Vehicle { int y; Car() { super(10); // line n2 } Car(int y) { super(y); this.y = y; } public String toString() { return super.x + ":" + this.y; } } public class Test { public static void main(String[] args) { Vehicle y = new Car(20); System.out.println(y); } }
upvoted 1 times
...
iSnover
2 years, 3 months ago
Selected Answer: C
The answer is the letter C, the code compiles normally and prints 20:20, remember that if the constructor of Car has a super for that of Vehicle, then the same value remains for the 2 to change.
upvoted 1 times
...
shivkumarx
2 years, 4 months ago
Result of below code is: 20:20 public class A2 { int x; A2(){ this(10); } A2( int x){ this.x = x; } public static void main(String[] args) { A2 y = new Car(20); System.out.println(y); } } class Car extends A2{ int y; Car(){ super(10); } Car(int y){ super(y); this.y = y; } public String toString() { return super.x + ":" + this.y; } }
upvoted 4 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