Declaration and Access Control Name the keyword that makes a variable belong to a class, rather than being defined for each instance of the class. static native final volatile abstract static native final volatile abstract ANSWER DOWNLOAD EXAMIANS APP
Declaration and Access Control You have the following code in a file called Test.javaclass Base{ public static void main(String[] args){ System.out.println("Hello"); }}public class Test extends Base{}What will happen if you try to compile and run this? Compiles and runs with no output. Compiles and runs printing Runtime error It will fail to compile. Compiles and runs with no output. Compiles and runs printing Runtime error It will fail to compile. ANSWER DOWNLOAD EXAMIANS APP
Declaration and Access Control 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(); }} None of these static block A A A block static static A None of these static block A A A block static static A ANSWER DOWNLOAD EXAMIANS APP
Declaration and Access Control 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;}} IllegalArgumentException is thrown at runtime. Compilation error. InsideDemo 10 Hello2 hello1 Hello2 InsideDemo 10 InsideDemo 10 Hello2 IllegalArgumentException is thrown at runtime. Compilation error. InsideDemo 10 Hello2 hello1 Hello2 InsideDemo 10 InsideDemo 10 Hello2 ANSWER DOWNLOAD EXAMIANS APP
Declaration and Access Control What can directly access and change the value of the variable qusNo?package com.mypackage;public class Test{ private int qusNo = 100;} Only the Test class. Any class. Any class in com.mypackage package. Any class that extends Test. None of these Only the Test class. Any class. Any class in com.mypackage package. Any class that extends Test. None of these ANSWER DOWNLOAD EXAMIANS APP
Declaration and Access Control What will be the output?public class Test{static{int a = 5;}public static void main(String args[]){new Test().call();}void call(){this.a++;System.out.print(this.a);}} 0 Runtime Exception 6 Compile with error 5 0 Runtime Exception 6 Compile with error 5 ANSWER DOWNLOAD EXAMIANS APP