JAVA Constructors and Methods Which of the modifier can't be used for constructors? public private static protected public private static protected ANSWER DOWNLOAD EXAMIANS APP
JAVA Constructors and Methods public class MyClass{ }For the above class(MyClass) what is the correct way of declaring constructor? MyClass(){} public MyClass(void){} MyClass(void) {} 1 and 3 public MyClass(){} MyClass(){} public MyClass(void){} MyClass(void) {} 1 and 3 public MyClass(){} ANSWER DOWNLOAD EXAMIANS APP
JAVA Constructors and Methods The implicit return type of a constructor is A class object in which it is defined. There is no return type. None of these void A class object in which it is defined. There is no return type. None of these void ANSWER DOWNLOAD EXAMIANS APP
JAVA Constructors and Methods The variables declared in a class for the use of all methods of the class are called instance variables reference variables None of these objects instance variables reference variables None of these objects ANSWER DOWNLOAD EXAMIANS APP
JAVA Constructors and Methods 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(); }} None of these Compilation Error two one one one one two one Exception None of these Compilation Error two one one one one two one Exception ANSWER DOWNLOAD EXAMIANS APP
JAVA Constructors and Methods 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 10 50 Won't compile because of line (1); constructor can't be private Won't compile because of line (5); constructor can't be final 50 10 50 Won't compile because of line (1); constructor can't be private Won't compile because of line (5); constructor can't be final ANSWER DOWNLOAD EXAMIANS APP