Name the keyword that makes a variable belong to a class, rather than being defined for each instance of the class. abstract static volatile native final TRUE ANSWER : ? YOUR ANSWER : ?
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);}} 0 6 5 Compile with error Runtime Exception TRUE ANSWER : ? YOUR ANSWER : ?
What will be the output after the following program is compiled and executed?public class Test{ public static void main(String args[]){ int x = 10; x = myMethod(x--); System.out.print(x); } static int myMethod(final int x){ return x--; }} None of these The program will lead to compilation error. The program will lead to runtime error. The program will compile successfully and display 10 as output. The will compile successfully and display 9 as output. TRUE ANSWER : ? YOUR ANSWER : ?
A package is a collection of Classes Interfaces Editing tools and Interfaces Editing tools Classes and Interfaces TRUE ANSWER : ? YOUR ANSWER : ?
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(); }} Exception is thrown at runtime BaseDerived Compilation Error Derived TRUE ANSWER : ? YOUR ANSWER : ?
Choose the correct statementpublic class Circle{ private double radius; public Circle(double radius){ radius = radius; }} The program has a compilation error because it does not have a main method. The program does not compile because Circle does not have a default constructor. 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 has a compilation error because we cannot assign radius to radius. TRUE ANSWER : ? YOUR ANSWER : ?
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. Compiles and runs printing It will fail to compile. Runtime error TRUE ANSWER : ? YOUR ANSWER : ?
What will be the output for the below code?public class Test{ static{ int a = 5; } public static void main(String[] args){ System.out.println(a); }} Compile with error Runtime Exception None of these 5 0 TRUE ANSWER : ? YOUR ANSWER : ?
What will be the output?public class Test{ public static void main(String[] args){ String value = "abc"; changeValue(value); System.out.println(value); } public static void changeValue(String a){ a = "xyz"; }} None of these Compilation clean but no output abc Compilation fails xyz TRUE ANSWER : ? YOUR ANSWER : ?
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) TRUE ANSWER : ? YOUR ANSWER : ?