πŸ“Š JAVA
Q. What will be the result of compiling and running the given code?
class A{
int b=10;
private A(){
this.b=7;
}
int f(){
return b;
}
}
class B extends A{
int b;
}
public class Test{
public static void main(String[] args){
A a = new B();
System.out.println(a.f());
}
}
  • (A) Compilation Fails
  • (B) Prints 0
  • (C) Prints 10
  • (D) Prints 10 D. Prints 7
πŸ’¬ Discuss
βœ… Correct Answer: (A) Compilation Fails

Explanation: Choice A is the correct answer.

Explanation by: Gopal Sharma
Choice A is the correct answer.

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
107
Total Visits
πŸ“½οΈ
12 mo ago
Published
πŸŽ–οΈ
Gopal Sharma
Publisher
πŸ“ˆ
84%
Success Rate