πŸ“Š JAVA
Q. What is the output for the below code?
public class A{
static{
System.out.println("static");
}

{
System.out.println("block");
}

public A(){
System.out.println("A");
}

public static void main(String[] args){
A a = new A();
}
}
  • (A) A block static
  • (B) static block A
  • (C) static A
  • (D) static A D. A
πŸ’¬ Discuss
βœ… Correct Answer: (B) static block A

Explanation: First execute static block, then statement block and then constructor.

Explanation by: Bhagwan Das
First execute static block, then statement block and then constructor.

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
114
Total Visits
πŸ“½οΈ
12 mo ago
Published
πŸŽ–οΈ
Bhagwan Das
Publisher
πŸ“ˆ
98%
Success Rate