JAVA Constructors and Methods What will be the return type of a method that not returns any value? int None of these double void int None of these double void 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 two one one Compilation Error one one two one Exception None of these two one one Compilation Error one one two one Exception ANSWER DOWNLOAD EXAMIANS APP
JAVA Constructors and Methods class A{ A(String s){} A(){}}1. class B extends A{2. B(){}3. B(String s){4. super(s);5. }6. void test(){7. // insert code here8. }9. }Which of the below code can be insert at line 7 to make clean compilation ? A a = new B(5); A a = new B(); A a = new A(String s); None of these All of these A a = new B(5); A a = new B(); A a = new A(String s); None of these All of these ANSWER DOWNLOAD EXAMIANS APP
JAVA Constructors and Methods What is the expected output?public class Profile { private Profile(int w) { // line 1 System.out.print(w); } public static Profile() { // line 5 System.out.print (10); } public static void main(String args[]) { Profile obj = new Profile(50); }} 10 50 Won't compile because of line (1), constructor can't be private 50 Won't compile because of line (5), constructor can't be static 10 50 Won't compile because of line (1), constructor can't be private 50 Won't compile because of line (5), constructor can't be static ANSWER DOWNLOAD EXAMIANS APP
JAVA Constructors and Methods public class MyClass{ }For the above class(MyClass) what is the correct way of declaring constructor? 1 and 3 MyClass(){} MyClass(void) {} public MyClass(void){} public MyClass(){} 1 and 3 MyClass(){} MyClass(void) {} public MyClass(void){} public MyClass(){} ANSWER DOWNLOAD EXAMIANS APP
JAVA Constructors and Methods What is the output for the below code ?class A{ public A(){ System.out.println("A"); } public A(int i){ this(); System.out.println(i); }}class B extends A{ public B(){ System.out.println("B"); } public B(int i){ this(); System.out.println(i+3); }}public class Test{ public static void main (String[] args){ new B(5); }} A B 8 B 8 A 5 A 5 B 8 None of these A B 5 A B 8 B 8 A 5 A 5 B 8 None of these A B 5 ANSWER DOWNLOAD EXAMIANS APP