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) and (II) (I), (II) and (III) Only (III) (II) and (III) Only (I) (I) and (II) (I), (II) and (III) Only (III) (II) and (III) 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;} Any class that extends Test. Any class in com.mypackage package. Any class. None of these Only the Test class. Any class that extends Test. Any class in com.mypackage package. Any class. None of these Only the Test class. ANSWER DOWNLOAD EXAMIANS APP
Declaration and Access Control What will be the output after compiling and running following program code?public class Test{ static int a; public static void main(String[] args){ System.out.println("one"); call(1); } static void call(int a){ this.a=10; System.out.println("two "+a); }} one two 1 one two 10 Compile time error. None of these one two 0 one two 1 one two 10 Compile time error. None of these one two 0 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 printing Runtime error Compiles and runs with no output. It will fail to compile. Compiles and runs printing Runtime error Compiles and runs with no output. It will fail to compile. 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? Do not declare the method with any accessibility modifiers. Declare the method with the keyword private. Declare the method with the keyword protected. Declare the method with the keyword public. Declare the method with the keyword public and private. Do not declare the method with any accessibility modifiers. Declare the method with the keyword private. Declare the method with the keyword protected. Declare the method with the keyword public. Declare the method with the keyword public and private. 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 A None of these A block static static block A A static A None of these A block static static block A ANSWER DOWNLOAD EXAMIANS APP