Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (45k points)

public class MyFirst { 

      public static void main(String[] args) { 

         MyFirst obj = new MyFirst(n); 

 } 

 static int a = 10; 

 static int n; 

 int b = 5; 

 int c;  

 public MyFirst(int m) { 

       System.out.println(a + ", " + b + ", " + c + ", " + n + ", " + m); 

   } 

// Instance Block 

  { 

     b = 30; 

     n = 20; 

  }  

// Static Block 

  static  

          a = 60; 

     }  

 } 

A) 10, 5, 0, 20, 0

B) 10, 30, 20

C) 60, 5, 0, 20

D) 60, 30, 0, 20, 0

1 Answer

0 votes
by (99k points)

The correct answer to the question “What will be the output of the following Java program” is option (d). 60, 30, 0, 20, 0. And all the other options are incorrect. If you wish to learn Java and then get trained, by enrolling in Intellipaat’s Java certification course. Also, look at the latest YouTube video on Java Interview Questions and Answers.

Related questions

0 votes
1 answer
0 votes
2 answers
0 votes
1 answer

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...