Answer to Question #192399 in Java | JSP | JSF for Phil

Question #192399

10. Given the following code, the output is __. Please select "A, B, C, D, or E" as correct option. 


class Parent

{

private int x = 5;

int show() { x = 6; return x; }

}

class Child extends Parent

{

public int x = 7;

public Child() { x = 8; x++; x = super.show(); }

}

class Sample

{

public static void main(String[] args)

{

Child c1 = new Child();

System.out.print(c1.x);

}

}


A. 5

B. 6

C. 7

D. 8

E. 9


1
Expert's answer
2021-05-18T02:49:31-0400

Answer: B


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS