What is the expected output?public class Profile {private Profile(int w) { // line 1System.out.print(w);}public final Profile() { // line 5System.out.print(10);}public static void main(String args[]) {Profile obj = new Profile(50);}} 50 Won't compile because of line (5); constructor can't be final 10 50 Won't compile because of line (1); constructor can't be private TRUE ANSWER : ? YOUR ANSWER : ?
The implicit return type of a constructor is None of these void A class object in which it is defined. There is no return type. TRUE ANSWER : ? YOUR ANSWER : ?
What is the output for the below code?public class Test{ public static void printValue(int i, int j, int k){ System.out.println("int"); } public static void printValue(byte...b){ System.out.println("long"); } public static void main(String... args){ byte b = 9; printValue(b,b,b); }} None of these Compilation clean but throws RuntimeException Compilation fails int long TRUE ANSWER : ? YOUR ANSWER : ?
The variables declared in a class for the use of all methods of the class are called objects instance variables None of these reference variables TRUE ANSWER : ? YOUR ANSWER : ?
The following code contains one compilation error, find it?public class Test {Test() { } // line 1static void Test() { this(); } // line 2 public static void main(String[] args) { // line 3Test(); // line 4}} At line 1, constructor Tester must be marked public like its class At line 3, compilation error, ambiguity problem, compiler can't determine whether a constructor At line 2, constructor call At line 4 TRUE ANSWER : ? YOUR ANSWER : ?
In which area of memory, the system stores parameters and local variables whenever a method is invoked? Storage Area Stack Array Heap TRUE ANSWER : ? YOUR ANSWER : ?
Which of these is a legal definition of a method named examveda assuming it throws IOException, and returns void. Also assume that the method does not take any arguments. Select the one correct answer. examians() throws IOException{} void examians() throws IOException{} void examians() throw IOException{} void examians(void) throws IOException{} void examians() {} throws IOException TRUE ANSWER : ? YOUR ANSWER : ?
The main method should be static for the reason It can be executed without creating any instance of the class. None of these It can be accessed easily by the class loader. It can be accessed by every method or variable without any hindrance. TRUE ANSWER : ? YOUR ANSWER : ?
public class Test { }What is the prototype of the default constructor? Test( ) public Test( ) None of these Test(void) public Test(void) TRUE ANSWER : ? YOUR ANSWER : ?
class MyClass{ MyClass(){ System.out.print("one"); } public void myMethod(){ this(); System.out.print("two"); }} public class TestClass{ public static void main(String args[]){ MyClass obj = new MyClass(); obj.myMethod(); }} one one two Compilation Error one Exception None of these two one one TRUE ANSWER : ? YOUR ANSWER : ?