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. native volatile final static abstract native volatile final static abstract 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); }} 20 one two 20 one 20 one two one 20 one two 20 one 20 one two one 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 public and private. Do not declare the method with any accessibility modifiers. Declare the method with the keyword protected. Declare the method with the keyword public. Declare the method with the keyword private. Declare the method with the keyword public and private. Do not declare the method with any accessibility modifiers. Declare the method with the keyword protected. Declare the method with the keyword public. Declare the method with the keyword private. 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);}} 6 0 Runtime Exception 5 Compile with error 6 0 Runtime Exception 5 Compile with error 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 with no output. Runtime error Compiles and runs printing It will fail to compile. Compiles and runs with no output. Runtime error Compiles and runs printing It will fail to compile. ANSWER DOWNLOAD EXAMIANS APP
Declaration and Access Control Choose the correct statementpublic class Circle{ private double radius; public Circle(double radius){ radius = radius; }} The program does not compile because Circle does not have a default constructor. The program has a compilation error because we cannot assign radius to radius. The program has a compilation error because it does not have a main method. The program will compile, but we cannot create an object of Circle with a specified radius. The object will always have radius 0. The program does not compile because Circle does not have a default constructor. The program has a compilation error because we cannot assign radius to radius. The program has a compilation error because it does not have a main method. The program will compile, but we cannot create an object of Circle with a specified radius. The object will always have radius 0. ANSWER DOWNLOAD EXAMIANS APP