JAVA Constructors and Methods 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. void examians(void) throws IOException{} examians() throws IOException{} void examians() throws IOException{} void examians() {} throws IOException void examians() throw IOException{} void examians(void) throws IOException{} examians() throws IOException{} void examians() throws IOException{} void examians() {} throws IOException void examians() throw IOException{} ANSWER DOWNLOAD EXAMIANS APP
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);}} Method 1 None of these Compile time error as final method can't be overloaded Method 2 Method 1 None of these Compile time error as final method can't be overloaded Method 2 ANSWER DOWNLOAD EXAMIANS APP
JAVA Constructors and Methods Determine output:public class Test{ public static void main(String args[]){ MyClass obj = new MyClass(); obj.val = 1; obj.call(obj); System.out.println(obj.val); }}class MyClass{ public int val; public void call(MyClass ref){ ref.val++; }} 1 Compilation Error None of these 2 3 1 Compilation Error None of these 2 3 ANSWER DOWNLOAD EXAMIANS APP
JAVA Constructors and Methods What is the output of the above program ?class Num { Num(double x ){ System.out.println( x ) ; } }public class Test extends Num { public static void main(String[] args){ Num num = new Num( 2 ) ; } } None of these 0 2.0 Compile time error None of these 0 2.0 Compile time error 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 Won't compile because of line (1); constructor can't be private Won't compile because of line (5); constructor can't be final 10 50 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 10 50 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