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);}} Compile with error 6 5 0 Runtime Exception Compile with error 6 5 0 Runtime Exception ANSWER DOWNLOAD EXAMIANS APP
Declaration and Access Control What will be the output for the below code?static public class Test{ public static void main(String[] args){ char c = 'a'; switch(c){ case 65 : System.out.println("one");break; case 'a': System.out.println("two");break; case 3 : System.out.println("three"); } }} Compile error - Illegal modifier for the class Test; only public, abstract & final are permitted. Compile error - char can't be permitted in switch statement. two one None of these Compile error - Illegal modifier for the class Test; only public, abstract & final are permitted. Compile error - char can't be permitted in switch statement. two one None of these 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. Hello2 InsideDemo 10 Compilation error. InsideDemo 10 Hello2 hello1 InsideDemo 10 Hello2 IllegalArgumentException is thrown at runtime. Hello2 InsideDemo 10 Compilation error. InsideDemo 10 Hello2 hello1 InsideDemo 10 Hello2 ANSWER DOWNLOAD EXAMIANS APP
Declaration and Access Control A package is a collection of Classes Classes and Interfaces Interfaces Editing tools Editing tools and Interfaces Classes Classes and Interfaces Interfaces Editing tools Editing tools and Interfaces ANSWER DOWNLOAD EXAMIANS APP
Declaration and Access Control A method within a class is only accessible by classes that are defined within the same package as the class of the method. Which one of the following is used to enforce such restriction? Declare the method with the keyword protected. Declare the method with the keyword public and private. Declare the method with the keyword private. Do not declare the method with any accessibility modifiers. Declare the method with the keyword public. Declare the method with the keyword protected. Declare the method with the keyword public and private. Declare the method with the keyword private. Do not declare the method with any accessibility modifiers. Declare the method with the keyword public. ANSWER DOWNLOAD EXAMIANS APP
Declaration and Access Control Choose all the lines which if inserted independently instead of "//insert code here" will allow the following code to compile:public class Test{ public static void main(String args[]){ add(); add(1);add(1, 2); }// insert code here} static void add(int... args, int y){} void add(Integer... args){} static void add(int[]... args){} static void add(int args...){} static void add(int...args){} static void add(int... args, int y){} void add(Integer... args){} static void add(int[]... args){} static void add(int args...){} static void add(int...args){} ANSWER DOWNLOAD EXAMIANS APP