exam questions

Exam 1z0-819 All Questions

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

Exam 1z0-819 topic 1 question 54 discussion

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

Given:



and



and



What is the result?

  • A. 42
  • B. The compilation fails due to an error in line 1.
  • C. The compilation fails due to an error in line 2.
  • D. The compilation fails due to an error in line 3.
  • E. The compilation fails due to an error in line 4.
  • F. The compilation fails due to an error in line 5.
  • G. 17
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
ASPushkin
5 months, 4 weeks ago
Selected Answer: A
public class A { public int x = 42; public class B extends A { int x = 17 Unlike methods, fields in a subclass hide those of the same name in the superclass. Therefore, the fields in the subclass don't need to have equal-or-less restrictive access modifier than the hidden fields. ------- protected A() {} public B() {super();} because of "protected" super constructor is visible from class B. ------- In Java fields and static methods aren't polymorphic. A obj = new B(); System.out.println(obj.x); That means obj.x is the field of the reference type (A obj =.. ).
upvoted 1 times
...
d7bb0b2
1 year, 1 month ago
A is correct because, constructor has a protected modified, so child class can see that constructor, and instance variables not override. if father class has a default access this would be a compilation error cause chid class cannot see the super constructor of father class
upvoted 1 times
d7bb0b2
1 year ago
the static method and variables are acceses by the Type of object not the real object. so x in A is acceded. if B obj = new B(); => then x in b is printed
upvoted 1 times
...
...
Omnisumem
1 year, 5 months ago
Selected Answer: A
Tested: A!
upvoted 1 times
...
tmuralimanohar
1 year, 7 months ago
Answer:A
upvoted 1 times
...
Stavok
1 year, 8 months ago
Selected Answer: A
A is correct
upvoted 1 times
...
RP384
1 year, 11 months ago
Selected Answer: A
42 will be output
upvoted 1 times
...
TADIEWA
2 years, 1 month ago
A is correct you cannot override instance variables
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