JAVA Constructors and Methods The variables declared in a class for the use of all methods of the class are called reference variables objects instance variables None of these reference variables objects instance variables None of these ANSWER DOWNLOAD EXAMIANS APP
JAVA Constructors and Methods What is the output of the program?class Test{ public int display(int x, int y){ return ("The sum of x and y is " + x + y); } public static void main(String args[]){ Test test = new Test(); System.out.println(test.display(4,5)); } } None of these does not compile The sum of x and y is 9 The sum of x and y is 45 None of these does not compile The sum of x and y is 9 The sum of x and y is 45 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 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); }} 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 10 50 ANSWER DOWNLOAD EXAMIANS APP
JAVA Constructors and Methods Which of the following options is the best for generating random integer 0 or 1? (int)Math.random() (int)(Math.random() + 0.2) (int)Math.random() + 1 (int)(Math.random() + 0.5) (int)Math.random() (int)(Math.random() + 0.2) (int)Math.random() + 1 (int)(Math.random() + 0.5) 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 5 0 5 8 0 8 0 0 5 0 5 8 0 8 ANSWER DOWNLOAD EXAMIANS APP