JAVA Constructors and Methods Determine Output:class A{public static void method(int i){System.out.print("Method 1");}public static int method(String str){System.out.print("Method 2");return 0;}}public class Test{ public static void main(String args[]){A.method(5);}} None of these Method 1 Compile time error as final method can't be overloaded Method 2 None of these Method 1 Compile time error as final method can't be overloaded Method 2 ANSWER DOWNLOAD EXAMIANS APP
JAVA Constructors and Methods Which of the modifier can't be used for constructors? static public protected private static public protected private ANSWER DOWNLOAD EXAMIANS APP
JAVA Constructors and Methods What is the expected output?class Animal {Animal() {System.out.println("Animal");}}class Wild extends Animal{Wild() {System.out.println("Wild");super();}}public class Test {public static void main(String args[]) {Wild wild = new Wild();}} Wild Animal Compilation Error Runtime Exception Animal Wild Wild Animal Compilation Error Runtime Exception Animal Wild 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(); }} two one one Compilation Error None of these one one two one Exception two one one Compilation Error None of these one one two one Exception ANSWER DOWNLOAD EXAMIANS APP
JAVA Constructors and Methods Given the following piece of code:class Person{ public int number;}public class Test{ public void doIt(int i , Person p){ i = 5; p.number = 8; } public static void main(String args[]){ int x = 0; Person p = new Person(); new Test().doIt(x, p); System.out.println(x + " " + p.number); }}What is the result? 0 0 0 8 5 8 5 0 0 0 0 8 5 8 5 0 ANSWER DOWNLOAD EXAMIANS APP
JAVA Constructors and Methods class MyClass{int i;int j;public MyClass(int i, int j){this.i = i;this.j = j;}public void call(){System.out.print("One");}}public class Test{public static void main(String args[]){MyClass m = new MyClass(); //line 1m.call(); //line 2}} Compilation succeed but no output. Compilation fails due to an error on line 2 Compilation fails due to an error on line 1 One Compilation succeed but no output. Compilation fails due to an error on line 2 Compilation fails due to an error on line 1 One ANSWER DOWNLOAD EXAMIANS APP