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 final abstract volatile static native final abstract volatile static 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? This method is only accessible from inside the class itself and from inside all subclasses. In a class, you cannot declare methods with a lower visibility than the visibility of the class in which it is defined. 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. This method is only accessible from inside the class itself and from inside all subclasses. In a class, you cannot declare methods with a lower visibility than the visibility of the class in which it is defined. 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. 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. Do not declare the method with any accessibility modifiers. Declare the method with the keyword private. Declare the method with the keyword public. Declare the method with the keyword protected. 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 public. 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? 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. Compiles and runs with no output. 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;} Only the Test class. None of these Any class in com.mypackage package. Any class. Any class that extends Test. Only the Test class. None of these Any class in com.mypackage package. Any class. Any class that extends Test. 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"); } }} None of these Compile error - char can't be permitted in switch statement. Compile error - Illegal modifier for the class Test; only public, abstract & final are permitted. one two None of these Compile error - char can't be permitted in switch statement. Compile error - Illegal modifier for the class Test; only public, abstract & final are permitted. one two ANSWER DOWNLOAD EXAMIANS APP