exam questions

Exam 1z0-808 All Questions

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

Exam 1z0-808 topic 1 question 162 discussion

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

Given:

And the code fragment:

What is the result?

  • A. C1C2
  • B. C1C1
  • C. Compilation fails.
  • D. C2C2
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, 2 weeks ago
obj2 is C1 objectand C1 is a subclass of C2 so the down casting is correct. Answer is A
upvoted 1 times
...
carloswork
2 years, 2 months ago
Selected Answer: A
Answer is A. To test: Use the shortcut (Ctrl + Shift + f) in eclipse to fix the indentation in case the text appears badly formatted. interface I { public void displayI(); } abstract class C2 implements I { public void displayC2() { System.out.println("C2"); } } class C1 extends C2 { public void displayI() { System.out.print("C1"); } } public class Test { public static void main(String[] args) { C2 obj1 = new C1(); I obj2 = new C1(); C2 s = (C2) obj2; I t = obj1; t.displayI(); s.displayC2(); } }
upvoted 1 times
...
iSnover
2 years, 3 months ago
Selected Answer: A
The correct answer is the letter A, the cast can be done because "C1" can be "C2" as it inherits the methods of "C2" by inheritance. Printing C1C2.
upvoted 1 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