Question 1. What is the output of this question?
A) 10 10
B) 20 20
C) 10 20
D) 20 10
Explanation : instance variable is object level variable means for every object a separate copy of instance variable will be created.
Question 2. What is the output of this question?
A) 3 6 9
B) 3 6 9 …. 27
Explanation : Here local variables are printed after execution. If we want to execute static variables, then we write Test1.i or we write Test1 object.i.
Question 3. What is the output of this question?
A) 1 3 9
B) 1 2 3 … 9
C) 3 5 7 9 11 13 15 17 19
Explanation : Here, two different i copies of variable are declared, one is static and other one is local. If we write Test1.i then, static variable is executed and if we write only i, then local variable are executed.
Question 4. What is the output of this question?
B)1 3 9
C)3 5 7 9 11 13 15 17 19
D)1 2 3 … 9
Explanation : We can not declare the static variable inside the block. If we declare static variable inside the block, then we will get the compile time error : illegal start of expression.
Question 5. What is the output of this question?
Explanation :Here we are trying to declare array as static type but we can not declare the local array as static type. If we will try to declare the local variable as static, then will get error : illegal start of expression.
This article is contributed by Shivakant Jaiswal. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.