exam questions

Exam 1z0-819 All Questions

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

Exam 1z0-819 topic 1 question 58 discussion

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

Given:



What is the result?

  • A. AnotherClass#methodA()
    SomeClass#methodA()
  • B. A ClassCastException is thrown at runtime.
  • C. The compilation fails.
  • D. AnotherClass#methodA()
    AnotherClass#methodA()
  • E. SomeClass#methodA()
    AnotherClass#methodA()
  • F. SomeClass#methodA()
    SomeClass#methodA()
Show Suggested Answer Hide Answer
Suggested Answer: C 🗳️
Community vote distribution
C (100%)

Comments

Chosen Answer:
This is a voting comment. You can switch to a simple comment. It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
ASPushkin
7 months, 1 week ago
Selected Answer: C
answer : C Conversion of Reference Types Downcasting It’s the casting from a superclass to a subclass. An explicit cast is required. llegitimate narrowing results in a ClassCastException. ac = (AnotherClass)sc; throw runtime ClassCastException ac = sc; Compilation eror error: incompatible types:
upvoted 1 times
...
aruni_mishra
8 months, 3 weeks ago
C. superclass reference cannot be assigned to subclass reference without explicit cast.
upvoted 1 times
...
mrc61
11 months, 3 weeks ago
SomeClass cannot be converted to AnotherClass C. public class q58 { public static void main(String[] args) { AnotherClass ac = new AnotherClass(); SomeClass sc = new AnotherClass(); ac = sc; // sc = ac; sc.methodA(); ac.methodA(); } } class SomeClass { public void methodA() { System.out.println("Some Class #methodA ()"); } } class AnotherClass extends SomeClass { public void methodA() { System.out.println("AnotherClass#methodA() "); } }
upvoted 2 times
...
mendjijet
1 year, 1 month ago
Selected Answer: C
C is correct
upvoted 1 times
...
d7bb0b2
1 year, 3 months ago
C is correct, child variable cannot be a parent reference
upvoted 1 times
...
Omnisumem
1 year, 6 months ago
Selected Answer: C
Tested: C.
upvoted 1 times
...
tmuralimanohar
1 year, 8 months ago
Answer: C
upvoted 1 times
...
Stavok
1 year, 9 months ago
Selected Answer: C
C is Correct Type mismatch: cannot convert from SomeClass to AnotherClass
upvoted 1 times
...
RP384
2 years, 1 month ago
Selected Answer: C
child type cannot hold parent type reference
upvoted 1 times
...
Ankit1010
2 years, 1 month ago
C is the correct answer; Required type: AnotherClass Provided: SomeClass
upvoted 1 times
...
TADIEWA
2 years, 2 months ago
c , child type cannot hold parent type reference , incompatible types .... but a parent type reference can hold up child type reference
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:
CAS-004
Madrid, 1 minute ago