JAVA Constructors and Methods Determine output of the following program.public class Test{ public static void main(String args[]){ System.out.println( Math.floor( Math.random( ) ) ) ; }} 0.0 1.0 0.5 10.0 0.0 1.0 0.5 10.0 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 one Exception None of these Compilation Error one one two two one one one Exception None of these Compilation Error one one two 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}} One Compilation fails due to an error on line 1 Compilation fails due to an error on line 2 Compilation succeed but no output. One Compilation fails due to an error on line 1 Compilation fails due to an error on line 2 Compilation succeed but no output. ANSWER DOWNLOAD EXAMIANS APP
JAVA Constructors and Methods What will be the result of compiling and running the given code?class A{ int b=10; private A(){ this.b=7; } int f(){ return b; }}class B extends A{ int b;}public class Test{ public static void main(String[] args){ A a = new B(); System.out.println(a.f()); }} Compilation Fails Prints 7 Prints 0 Prints 10 None of these Compilation Fails Prints 7 Prints 0 Prints 10 None of these 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(void) {} MyClass(){} public MyClass(){} public MyClass(void){} 1 and 3 MyClass(void) {} MyClass(){} public MyClass(){} public MyClass(void){} 1 and 3 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();}} Runtime Exception Wild Animal Animal Wild Compilation Error Runtime Exception Wild Animal Animal Wild Compilation Error ANSWER DOWNLOAD EXAMIANS APP