Exam 1z0-819 All QuestionsBrowse all questions from this exam
Question 26

Given:

and

Which four identifiers from the Foo and Bar classes are visible at line 1? (Choose four.)

    Correct Answer: A, B, D, H

    The identifiers that are visible at line 1 in the Bar class method are determined by their access modifiers. The variable 'e' is protected, making it accessible in subclasses even if they are in a different package. The variable 'f' is public, so it is accessible everywhere. The parameter 'j' is a local variable from the overridden foo method, so it is accessible within its method. The variable 'B' is public static final, so it is accessible from any class. Therefore, the identifiers visible are 'e', 'f', 'j', and 'B'.

Discussion
Mukes877Options: ABDH

e,f,J,B are visible at line 1 because they are public and protected other will not because whether they are private or Default So correct is ABDH

SuperDabichoOptions: ABDH

tested. default/package variables won't be visible. and h is the parameter for the Foo class constructor, not for Bar's constructor.

d7bb0b2Options: ABEF

public class Foo { static final int A = 0; public static final int B = 0; private static final int C = 0; int d = 0; protected int e = 0; public int f = 0; private int g = 0; public void foo(int h){ int i = 0; } } IN OTHER PACKAE ONLY ACCESS: public void foo(int j) { System.out.println(B); System.out.println(e); System.out.println(f); System.out.println(j); }

RoxyFoxyOptions: ABDH

I tested this code: public class Bar extends com.foo.Foo{ @Override public void foo(int j){ System.out.println(super.B+" "+new Bar().e+" "+new Bar().f+ " "+ j); } public static void main(String[] args) { Bar bar = new Bar(); bar.foo(5); }} The output is: 0 0 0 5, so the correct answer: A B D H (with identifiers: e, f, j, B)

StavokOptions: ABDH

ABDH is correct

aruni_mishraOptions: ABDH

Answer: ABDH e: Protected, visible outside package by subclass only f: public j: overridden function's parameter B: public

pikosssOptions: ABEG

update*

pikosss

A-B-D-E

pikosssOptions: ABHI

tested

pikosss

A-B-D-E