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. (I) and (II) Only (I) Only (III) (II) and (III) (I), (II) and (III) (I) and (II) Only (I) Only (III) (II) and (III) (I), (II) and (III) ANSWER DOWNLOAD EXAMIANS APP
Declaration and Access Control The object is created with new keyword At run-time None of these At Compile-time Depends on the code At run-time None of these At Compile-time Depends on the code 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;}} InsideDemo 10 Hello2 IllegalArgumentException is thrown at runtime. Hello2 InsideDemo 10 InsideDemo 10 Hello2 hello1 Compilation error. InsideDemo 10 Hello2 IllegalArgumentException is thrown at runtime. Hello2 InsideDemo 10 InsideDemo 10 Hello2 hello1 Compilation error. 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(); }} static block A A block static A None of these static A static block A A block static A None of these static A ANSWER DOWNLOAD EXAMIANS APP
Declaration and Access Control What will be the output?public class Test{ public static void main(String[] args){ String value = "abc"; changeValue(value); System.out.println(value); } public static void changeValue(String a){ a = "xyz"; }} xyz Compilation fails None of these abc Compilation clean but no output xyz Compilation fails None of these abc Compilation clean but no 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(); }} Exception is thrown at runtime BaseDerived Compilation Error Derived Exception is thrown at runtime BaseDerived Compilation Error Derived ANSWER DOWNLOAD EXAMIANS APP