exam questions

Exam 1z0-808 All Questions

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

Exam 1z0-808 topic 1 question 202 discussion

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

Given:
and the code fragment:
S2 sobj = new S2();
sobj.display(10, 100);
What is the result?

  • A. Child 10 Child 100 Parent 100
  • B. Parent 10 Child 10 Parent 1000
  • C. Child 10 Parent 100 Parent 100
  • D. A compile time error occurs.
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, 1 week ago
Selected Answer: A
super can be called at any time in a method, but inside a constructor it must be called called first. Good answer is A
upvoted 1 times
...
Sisar
4 months, 1 week ago
Selected Answer: A
Correct is A. Tested
upvoted 1 times
...
amit_lad88
1 year ago
The correct answer is A. it will print Child10 Child100 Parent100
upvoted 3 times
...
Jess1985B
1 year, 1 month ago
A is correct, tested
upvoted 2 times
...
DriftKing
1 year, 4 months ago
The answer is A, I tested. But why don't we get compilation error as super and this are supposed to be first statement in a constructor ? Can someone explain?
upvoted 1 times
ManuTov
1 year, 2 months ago
super.display() invoke S1 display method. need to be aware its not be using "super()". The same thing is happening with this.display() its invoke a method too, not be using "this()"
upvoted 1 times
ManuTov
1 year, 2 months ago
display() is been overloading & overriding. JVM will automatically create a default constructor to initialize all fields (which in these cases there are no any attribute fields)
upvoted 1 times
...
...
...
kuuu
1 year, 11 months ago
Selected Answer: A
Answer is A , straight forward
upvoted 2 times
...
carloswork
2 years, 2 months ago
Selected Answer: A
Answer is A. UAK94 provided us the source code, in their comment.
upvoted 1 times
...
UAK94
2 years, 2 months ago
Answer is A. class S1 { protected void display(int x) { System.out.println("Parent" + x); } } public class S2 extends S1 { public void display(int x, int y) { this.display(x); display(y); super.display(y); } public void display(int x) { System.out.println("Child" + x); } public static void main(String[] args) { S2 sobj = new S2(); sobj.display(10, 100); // Child10 Child100 Parent100 } }
upvoted 2 times
...
alex_au
2 years, 2 months ago
Answer should be A. The Main method not found is just the omitted part of this question.
upvoted 1 times
...
iSnover
2 years, 2 months ago
Selected Answer: D
The correct answer is letter D, a super has to be instantiated first in a method.
upvoted 2 times
alex_au
2 years, 2 months ago
JVM will automatically create a default constructor to initialize all fields (which in these cases there are no any attribute fields) so there will be no any compile time error.
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