Declaration and Access Control Choose the correct statement. Restriction on static methods are: I. They can only call other static methods.II. They must only access static data.III. They cannot refer this or super in any way. Only (I) (I), (II) and (III) Only (III) (II) and (III) (I) and (II) Only (I) (I), (II) and (III) Only (III) (II) and (III) (I) and (II) 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);}} 5 6 Compile with error 0 Runtime Exception 5 6 Compile with error 0 Runtime Exception ANSWER DOWNLOAD EXAMIANS APP
Declaration and Access Control What will be the output after the following program is compiled and executed?public class Test{ public static void main(String args[]){ int x = 10; x = myMethod(x--); System.out.print(x); } static int myMethod(final int x){ return x--; }} The program will compile successfully and display 10 as output. The program will lead to compilation error. The program will lead to runtime error. None of these The will compile successfully and display 9 as output. The program will compile successfully and display 10 as output. The program will lead to compilation error. The program will lead to runtime error. None of these The will compile successfully and display 9 as output. ANSWER DOWNLOAD EXAMIANS APP
Declaration and Access Control What is the result of compiling and running the following code?class Base{ private Base(){ System.out.print("Base"); }}public class test extends Base{ public test(){ System.out.print("Derived"); } public static void main(String[] args){ new test(); }} Compilation Error Derived Exception is thrown at runtime BaseDerived Compilation Error Derived Exception is thrown at runtime BaseDerived ANSWER DOWNLOAD EXAMIANS APP
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. final volatile static native abstract final volatile static native abstract ANSWER DOWNLOAD EXAMIANS APP
Declaration and Access Control What will be the output for the below code?public class Test{ static{ int a = 5; } public static void main(String[] args){ System.out.println(a); }} None of these 5 Compile with error 0 Runtime Exception None of these 5 Compile with error 0 Runtime Exception ANSWER DOWNLOAD EXAMIANS APP