Home / Programming MCQs / JAVA MCQs / Question
J
Q. Determine output
public class InitDemo{ static int i = demo(); static{ System.out.print(i); } InitDemo(){ System.out.print("hello1"); } public static void main(String... args){ System.out.print("Hello2"); } static int demo(){ System.out.print("InsideDemo"); return 10; } }
As soon as the class are loaded static variables are initialized first. To initialize it demo must be called first then then static block executes and then main method is called.
You must be Logged in to update hint/solution
What is the output of the Java code snippet?
The client requests a connection to a server using which of the following statement?
Which of the following is NOT an example of a data type?
In Java, local variables are stored in __ memory and instance variables are stored in ___ memory.
Which of the following is a valid way to declare a multi-dimensional array in Java?
Which of the following is a type of polymorphism in Java?
What is the output of the Java program?
Which keyword is used for the block to handle the exceptions generated by try block?
What type of Java Programs can be run inside a Java supported Web Browser?
Which constructor creates an empty string buffer with the specified capacity as length.
Discusssion
Login to discuss.