Declaration and Access Control The object is created with new keyword None of these At Compile-time At run-time Depends on the code None of these At Compile-time At run-time Depends on the code 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(); }} BaseDerived Exception is thrown at runtime Derived Compilation Error BaseDerived Exception is thrown at runtime Derived Compilation Error 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); }} 5 None of these Compile with error 0 Runtime Exception 5 None of these Compile with error 0 Runtime Exception ANSWER DOWNLOAD EXAMIANS APP
Declaration and Access Control Determine output:class A{{System.out.print("b1 ");}public A(){System.out.print("b2 ");}}class B extends A{static{System.out.print("r1 ");}public B(){System.out.print("r2 ");}{System.out.print("r3 ");}static{System.out.print("r4 ");}}public class Test extends B{public static void main(String[] args){System.out.print("pre ");new Test();System.out.println("post ");}} Compilation fail r1 r4 pre b1 b2 post r3 r2 r1 r4 pre b1 b2 post pre r1 r4 b1 b2 r2 r3 post r1 r4 pre b1 b2 r3 r2 post Compilation fail r1 r4 pre b1 b2 post r3 r2 r1 r4 pre b1 b2 post pre r1 r4 b1 b2 r2 r3 post r1 r4 pre b1 b2 r3 r2 post 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(); }} A static block A None of these static A A block static A static block A None of these static A A block static ANSWER DOWNLOAD EXAMIANS APP
Declaration and Access Control Determine Output:class MyClass{ static final int a = 20; static final void call(){ System.out.println("two"); } static{ System.out.println("one"); }}public class Test{ public static void main(String args[]){ System.out.println(MyClass.a); }} one 20 one two 20 one one two 20 one 20 one two 20 one one two 20 ANSWER DOWNLOAD EXAMIANS APP