The object is created with new keyword None of these Depends on the code At Compile-time At run-time 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 Compile with error Runtime Exception 5 6 TRUE ANSWER : ? YOUR ANSWER : ?
A package is a collection of Editing tools Interfaces Classes Classes and Interfaces Editing tools and Interfaces 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--; }} The will compile successfully and display 9 as output. The program will lead to compilation error. The program will lead to runtime error. The program will compile successfully and display 10 as output. None of these TRUE ANSWER : ? YOUR ANSWER : ?
What can directly access and change the value of the variable qusNo?package com.mypackage;public class Test{ private int qusNo = 100;} Any class. None of these Any class in com.mypackage package. Any class that extends Test. Only the Test class. 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"; }} Compilation fails Compilation clean but no output None of these xyz abc TRUE ANSWER : ? YOUR ANSWER : ?
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(); }} None of these A A block static static block A static A TRUE ANSWER : ? YOUR ANSWER : ?
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); }} one two 20 one 20 one 20 one two TRUE ANSWER : ? YOUR ANSWER : ?
Name the keyword that makes a variable belong to a class, rather than being defined for each instance of the class. final abstract volatile native static 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. Runtime error It will fail to compile. Compiles and runs printing TRUE ANSWER : ? YOUR ANSWER : ?