Tuesday, June 11, 2024

What is output of the java program?Please select one option

 

  1. public class JavaTest {  
  2.       public void Method()   
  3.     {  
  4.     System.out.println("Method");  
  5.     }       
  6.     {  
  7.     System.out.println(" Instance Block");  
  8.     }            
  9.     public void JavaTest()  
  10.     {  
  11.     System.out.println("Constructor ");  
  12.     }  
  13.     static {  
  14.         System.out.println("static block");  
  15.     }  
  16.     public static void main(String[] args) {  
  17.     JavaTest c = new JavaTest();  
  18.     c.JavaTest();  
  19.     c.Method();  
  20.   }  
  21. }  
  22. a) Instance block, method, static block, and constructor
  23. b) Method, constructor, instance block, and static block
  24. c) Static block, method, instance block, and constructor
  25. d) Static block, instance block, constructor, and method
  26.  

No comments:

Post a Comment