You are on page 1of 2

First Milestone: Bank Of America, Java Induction

Name: Employee Id:


M. Time: 25min
1. final methods a. cannot be overloaded b. cannot be inherited c. cannot be overridden d. none of the above. 2. JVM is platform dependent 1.True 2.False 3. Where in a sub class constructor, can you place a call to a constructor defined in the super class? a) Anywhere b) The first statement in the constructor c) The last statement in the constructor d) You can't call super in a constructor 4) class A { public final void m1() {} } class B extends A { public void m1() {} } a)will not compile b)will compile but not run c) both a and b d) none of the above 5)An outer class cant be 1.private 2.public 3.default 4.protected 6. Method local inner class can not access local data of method in which it is defined 1. True 2. False 7. wait() and notify() method should be called in synchronized block 1. True 2. False 8. packages are used to a) avoid naming collisions between classes and interfaces b) to avoid variables names fron conflicts c) both a and b d) none of the above

void m1() { System.out.println("1");} } class B extends A { private void m1() { System.out.println("2");} } public class FreakCode { public static void main(String[] args) { A temp =new B(); temp.m1(); } } The below code will print A) 1 B) 2 C) Both 1 and 2 D) None of the above 10) following code snapshot is used in some code public static void print(int...c,int j) { } a) runtime error b) compile time error c)None of these 11) Which is true about multiple inheritance 1. Dont allow in java 2. Produce diamond problem 3. Can be done using interface 4. All are true

12) super class ref = subclass object cannot access a) functions of super class b) functions of sub class C) exclusive functions of subclass d) none of the function of subclass. Q13. class JMM107 { public static void main(String[] args) { boolean b = true; if (b = false) { System.out.print("A"); } else if (b) { System.out.print("B"); } else { System.out.print("C"); } } } What is the result of attempting to compile and run the program? a) A b) B C) C d) none of the above

9) class A {

Q 14: public class AQuestion { private int i = j; private int j = 10; public static void main(String args[]) { System.out.println((new AQuestion()).i); } } Answers 1. Compiler error complaining about access restriction of private variables of AQuestion. 2. Compiler error complaining about forward referencing. 3. No error - The output is 0; 4. No error - The output is 10; Q15. public interface AQuestion { void someMethod(); } The class which implements AQuestion 1. Should have someMethod which must necessarily be public. 2. Should have someMethod which could be "friendly" or public 3. Should have someMethod which cannot be sychronized as sychronized is not in the signature of the interface definition 4. None of these Q16. Which statement is true about reserve words in java 1. goto and const are unused keywords. They are reserved for future use. 2. null, true and false are not keywords. However, they cannot be used as identifiers. 3. Java classes are not keywords. 4. All are correct Q 17. float d=90.45; 1. Will give compilation error 2. Will compile Q18.public class DividebyZero { public static void main(String[] args) { int a,b,c; a=9; b=9; c=(a+b)/(a-b); System.out.println(c); } } 1. Will produce compile time problem 2. Will compile but fail at run time 3. Will compile and run 4. None of these Q19.Which statement is true 1. Run time exception happen at run time compile time exception happen at compile time 2. Run time exception happen at compile time compile time exception happen at run time 3. Both 1 and 2 4. All exception occur at run time only

Q20. consider int x[]=new int[4]; The size of array can be grown at compile time 1. True 2. False

Q21. Choose correct statement 1. Primitives is going to be stored in heap and objects are going to be stored in stack 2. Primitives is going to be stored in stack and objects are going to be stored in heap Q22. Abstraction means 1. Focus on essential things 2. Hiding necessary details 3. Both 4. None of these Q23. hashCode method must be used with a) List b) Map c) both d) none of the above. Q24. public class AQuestion { public static void main(String args[]) { System.out.println("Before Try"); try { } catch(Throwable t) { System.out.println("Inside Catch"); } System.out.println("At the End"); } } 1. Compiler error complaining about the catch block, where no Throwable object can ever be thrown. 2. Compiler error - Throwable Object can not be caught, only Exceptions must be caught. 3. No compiler error. The lines "Before Try" and "At the end" are printed on the screen. 4. None of these Q25. Read the following code carefully. public class AStringQuestion { static String s1; static String s2; public static void main(String args[]) { s2 = s1+s2; System.out.println(s2); } } Attempting to compile and run the code 1. Will cause a compilation error. 2. Runtime Execption - NullPointerException in the 2nd line of the main method. 3. Will compile successfully and print nullnull on the screen. 4. Will compile successfully and print an empty line on the screen.

You might also like