exam questions

Exam 1z0-808 All Questions

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

Exam 1z0-808 topic 1 question 233 discussion

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

Given the content from the Tree.java and Plant.java files:



and the code fragment:



Which code fragment is valid at line 10?

  • A. t.m1();
  • B. t.m1();
    t.m3();
  • C. t.m1();
    t.m2();
    t.m3();
    t.m4();
  • D. t.m1();
    t.m3();
    t.m4();
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 ago
Selected Answer: B
we can also access m3, AB is correct but B is complete.
upvoted 1 times
...
DriftKing
1 year, 3 months ago
Selected Answer: A
A. t.m1(); Incase you're wondering why we couldn't access m3 even though it's protected and protected methods can be accessed in different package with subclass - " The protected members are inherited by the child classes and can access them as its own members. But we can’t access these members using the reference of the parent class. We can access protected members only by using child class reference."
upvoted 2 times
DriftKing
1 year, 3 months ago
And in this case reference is of class Tree, so we couldn't access. If it was "Plant t = new Plant()" , we could have accessed m3.
upvoted 1 times
...
...
jackymak
1 year, 5 months ago
Selected Answer: A
package root; public class Tree { public void m1(){} private void m2(){} protected void m3(){} void m4(){} } ------------------------------------------------------------------ package branch; import root.Tree; public class Plant extends Tree{ public void m1(){} public void m2(){} public void m3(){} public void m4(){} public static void main(String[] args){ Tree t = new Plant(); t.m1(); // t.m2(); // t.m3(); // t.m4(); } } Because t is belong to Tree class
upvoted 3 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