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. None of these Only the Test class. Any class. Any class in com.mypackage package. Any class that extends Test. None of these Only the Test class. Any class. Any class in com.mypackage package. 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? It will fail to compile. Compiles and runs with no output. Compiles and runs printing Runtime error It will fail to compile. Compiles and runs with no output. Compiles and runs printing Runtime error ANSWER DOWNLOAD EXAMIANS APP
Declaration and Access Control Suppose a class has public visibility. In this class we define a protected method. Which of the following statements is correct? From within protected methods you do not have access to public methods. This method is accessible from within the class itself and from within all classes defined in the same package as the class itself. In a class, you cannot declare methods with a lower visibility than the visibility of the class in which it is defined. This method is only accessible from inside the class itself and from inside all subclasses. From within protected methods you do not have access to public methods. This method is accessible from within the class itself and from within all classes defined in the same package as the class itself. In a class, you cannot declare methods with a lower visibility than the visibility of the class in which it is defined. This method is only accessible from inside the class itself and from inside all subclasses. 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 10 one two 0 Compile time error. one two 1 None of these one two 10 one two 0 Compile time error. one two 1 None of these ANSWER DOWNLOAD EXAMIANS APP
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. abstract static native final volatile abstract static native final volatile 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(); }} Compilation Error BaseDerived Exception is thrown at runtime Derived Compilation Error BaseDerived Exception is thrown at runtime Derived ANSWER DOWNLOAD EXAMIANS APP