Which of the modifier can't be used for constructors? public private static protected TRUE ANSWER : ? YOUR ANSWER : ?
Which of the following options is the best for generating random integer 0 or 1? (int)Math.random() (int)Math.random() + 1 (int)(Math.random() + 0.5) (int)(Math.random() + 0.2) TRUE ANSWER : ? YOUR ANSWER : ?
In which area of memory, the system stores parameters and local variables whenever a method is invoked? Heap Array Storage Area Stack TRUE ANSWER : ? YOUR ANSWER : ?
The implicit return type of a constructor is void There is no return type. None of these A class object in which it is defined. TRUE ANSWER : ? YOUR ANSWER : ?
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()); }} Prints 10 Prints 7 Prints 0 None of these Compilation Fails TRUE ANSWER : ? YOUR ANSWER : ?
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{} void examians() throws IOException{} void examians() {} throws IOException examians() throws IOException{} void examians() throw IOException{} TRUE ANSWER : ? YOUR ANSWER : ?
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 Compilation Error one one two None of these TRUE ANSWER : ? YOUR ANSWER : ?
The variables declared in a class for the use of all methods of the class are called objects instance variables None of these reference variables TRUE ANSWER : ? YOUR ANSWER : ?
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 fails due to an error on line 2 Compilation succeed but no output. Compilation fails due to an error on line 1 One TRUE ANSWER : ? YOUR ANSWER : ?
What is the output for the below code?public class Test{ public static void printValue(int i, int j, int k){ System.out.println("int"); } public static void printValue(byte...b){ System.out.println("long"); } public static void main(String... args){ byte b = 9; printValue(b,b,b); }} Compilation clean but throws RuntimeException long int None of these Compilation fails TRUE ANSWER : ? YOUR ANSWER : ?