You are on page 1of 22
‘Two Threads A and B hit two different synchronized methods in an object at the same tme. Will they both continue? Which of the following option gives the valid cutcome for the above question? @ 2. Yes, because the methods are synchronized (© b. No, only one method can acquire the lock © ©.No, because the methods are synchronized © 4.Yes, two different threads hit Which of the following option gives the super type of all Annotation types? @ ©. java.lang.annotation Annotation © ©}. java.lang.Annotation © © Java.annotation.annotation d. There is no super typ for an Annotation type. An Annotation type is just an interface defintion Which of the following options give the valid methods that can be used for executing DDL statements? (Choose 2) a. execute) [D b. execurequery() [ « executeresult() d. executeUpdate() ‘Save without submitting ‘Submit all and finish Page: (Previous) 123.45 Consider the following scenario: ‘Two Threads A and 8 hit two different synchronized methods in an object at the same time. Will they both continue? Which of the following option gives the valid outcome for the above question? © 2. Yes, because the methods are synchronized . No, only one method can acquire the lock ¢. No, because the mathods are synchronized o0o0 d. Yes, two different threads hit Which of the following option gives the super type of all Annctation types? @ 3. javalang.annotation. Annotation ». java.lang Annotation . java.annotation Annotation oao d. There is ne super type for an Annetation type. An Annotation type is just an interface defintion Which of the following options give the valid methods that can be used for executing DDL statements? (Choose 2) a. execute!) b. executequery() [= exccuteresult() @ 4. executeUpdated Vhich of the following statement is true regarding psrameterized constructors? °o oO oO e 3. Parameterized constructors cannot call the default constructor b. Parameterized constructors cannot accept final arguments as paramaters c. Parameterized constructors cannot accept its same class type as parameter d. Parameterized constructors can accept variable arguments es their parameters Vhich of the following statement is true regarding constructers? oO ce} e ° 8. Abstract classes cannot have constructors b. Can be overloaded across inherited classes c. Default Constructors are optional only for the classes that does not have constructors d. Default Constructors are Optional for all classes consider the following scenario. wo Threads A and B hit two different synchronized methods in an object at the same time. Will they both ontinue?| hich of the following option gives the valid outcome for the above question? oo°0o a. Yes, because the methods are synchronized . No, only one method can acquire the lock c. No, because the mathods are synchronized d. Yes, two diferent threads hit A Employeet) <2 B. public Employee) ¢ ) C. private Employee() { } Consider the following statements: I. no-argument constructor, that does nat allow instantiation from within the package 11, no-argument constructor, that does not allow instantiaton fram outside the package TIL. no-argument constructor Which of the following option gives the exact matches of above listed items and statements? @ 244, em, cr © AMI, 841, CT © ¢ Ad, BH, CH © 4.84, 8-1, Cur HashMap is a Collection class. State TRUE or FALSE. answer Ome @ raise Which of the following statement gives the significance of overriding equals() method in user defined classes? © a. Comparing creation time of two objects © b. Comparing object Ids of two objects @ ©. Comparing content of two objects © 4. Comparing memory references of two objects ‘Save without submitting ‘Submit all and finish Page: (Previous) 1 2 3 4 5 (Next) Which of the following statement is false about for-each loop in Java? © 3: for-each loop dees the automatic typecasting ». for-each loop is an altemative to Enumeration ¢. for-each loop is an alternative to Iterator @oo d. for-each loop can work only with generic collections Consider the following listed items: A. Employea() { } E. public Employee() { } C. private Employee() ¢ } Consider the following statements: I. no-argument constructor, that does not allow instantiation from within the package Il, no-argument constructor, that does not allow instantiation from outside the package IM. no-argument constructor Which of the following option gives the exact matches of above listed items and statements? @ 2.80, 84,c1 © b-Adll, B+, CI © ¢ Ad, Bf, Cr © 4.A4,e4, cm HashMap is a Collection class. State TRUE or FALSE. Answer: OTe @Fase Consider the following list of items in Column A and column B ‘Column a. 1) Vector 2) HashSet 2) Treeset 4) ArrayList Column B. A) Itis not ordered or sorted 8) It compares and stores the data in a sorting order ©) Permits all elements including NULL. 1D) Ie ties to optimize storage management by maintaining a capacity and a capacty Increment. ‘Which of the following option gives the valid match between the Items in Column A and Statements in Column, 8? a. 2A, 4B, 3.C,1D b. 2-8, 3-8, 4-C, 1.0 © 1A 28, 3-C, 4D ooe@o d. 1-8, 3-8, 4-C, 2-0 Which of the following are true regarding Runtime€xception? (Choose 2) [1] @. Runtimetxception can be handled using a catch that handles Error b. Any class that derives the RuntimeException will always be an unchecked exception ¢ Runtimetxception does not require a throws declaration d. If Runtime xception is declared using throws clause, then the calling method should handle it using try-catch block ogg Which of the following statement is false about for-each loop in Java? Consider the following listed items: A Differing by Sionatures B. Code that executes before main) method C. Code that executes before constructor Consider the following statements: I Instance Block TI, Method Overloading Ill. Static Block Which of the following option gives the exact matches of above listed items and statements? © 2d, Bl, Cl b. Ac, BAM, Cl © AML, BA, Cl d. AL, BHIL, CH o°0oe Separation of object interactions from classes and inheritance into distinct layers of abstraction is called as a. Abstraction b. Cohesion c. Composition @eooo d. Decoupling Consider the following list of items in Column A end column B Column A. 1) Vector 2) HashSet 3) TreeSet 4) arrayList 75 Consider the following: Assume that there is a package structure as follows: com.testpack which contains a class called TestPack, with some static and non-static methods and a static inner class. Which of the following options give the valid import statements for the above package structure and class, in order to import the class TestPack or its members? (Choose 2) [2 import com.testpack.TestPack; [bs import com.testpack; [© import comtestpack-TestPack; JH 4. import static com.testpack.TestPack; Consider the following code snippet: 1) long test = 045; 2) float f = +132} 3) int value = fint)trus; 4) double d ~ 012345678; 5) short s = 20; \Which of the following option gives the legal assignments? @ 21245 © 6.12345 © 1234 © 41342 Set of services provided by a component or by a classis called @ 2. Interfaces © b. Objects © ¢.Components © 4.Containers Consider the following statement that represents a relationship: “Shyam has a best friend who is a Tree” Which of the following option represents the above relationship correctly? © a-dlass Shyam extends Tree { } b. class Shyam { private BestFriend Tree; } ° @ class Shyam ¢ private Tree bestfriend; } © 4.class shyam implements Tree ¢ > Which of the following statement is true? @ 2.Has-a relationships always rely on instance variables. © b. Has-a relationships always require at least two class types. © ¢-Has-a relationships always rely on inheritance. © d.Has.a relationships always rely on polymorphism. ‘Save without submitting ‘Submit all and finish Page: (Previous) 1 2 3 4 5 (Next) Consider the following interface declarations interface A {void main(String[] args);} 5 interface 8 {public void main(String{] args);> interface C {public static void mam(String[] args); interface D {protected void main(Stringl} args};> interface E {private void main(String[] args);) Which of the following option gives the valid interface declaration that will compile successfully? © @ interface 4.8.6 © b. interface 8,¢,D © interface B,C,.D @ G.interface A,B Set of services provided by a component or by a class is called © 2 Interfaces © b. Objects © © Components © 4. Containers Consider the following statement that represents a relationship. “shyam has a best friend who is a Tree” Which of the following option represents the above relationship correctly? © @-class Shyam extends Tree { } © b. dass Shyam { private BestFriend Tree; } @ © class Shyam { private Tree bestFriend; } © 4-ciass Shyam implements Tree { } Consider the following code: Line no:1 interface ione 5 Line no:2 {inti=20; } Line no:3 interface Two Line no:4 { int i=10; } Line no:5 public dass TestInterface implements iOne,iTwot Line no:6 public static void main(String[] a) Line no:7 { System.out-printin(); }> Which of the following option gives the valid output for the above code? © a0 @ ©. Compilation error at line no 7 © Runtime Error at line no 7 © 410 Which of the following statement gives the use of CLASSPATH? © 2: Holds the location of Java Extension Library @ . Holds the location of User Defined classes, packages and JARs © Holds the location of Java Software © 4. Holds the location of Core Java Class Library (Bootstrap classes) Consider the following interface declerations interface A {void main(String[] args);} 5_ interface B {public void main/String[] args);} interface C {public static void main(String{} args);} interface D {protected void main(Stringl] args):) interface E (private void main(Strinal] aras);> Which of the following option gives the valid interface declaration that will compile successfully? © avinterface 4,B,C Ah intarfare BOR, Consider the following cade: public class Testoverloading ¢ 75. int _length(String s) { ratirn s.length(): > float _length(String s) ¢ return (float) s.length0; y > Which of the following statement is true regarding the above code? @ 2 Both the length0 methods are duplicated methods b. Both the lengthO) methods are overloaded methods ¢. Overloaded methods cannot start with a special character like" oo d. Overloaded methods should be declared as public oO Which of the following statements is TRUE about StringBuffer class? a5 © @. StringBuffer can be extended, since it is mutable b. StringBuffer is a mutable class . StringBuffer is a sub dass of String class oe d. StringBuffer is a Wrapper to the existing String class °o Consider the following code: Line no:1 interface ine 7s Line no:2 {inti=10; } Line no:3 interface Two Consider the following statement about volatile key word in java Declaring a volatile Java variable means, the value of this variable will never be cached thread-locally: all reads and writes will go straight to “main memory"; State whether the above statement is TRUE or FALSE? answer: @tue OFalse, Consider the following code: class Smile ¢ protected joy h; class Happy extends smile { } class joy {) Which of the following statement is correct ragarding the above given cade? (© 2-Heppyis-a joy and has-a Smile. © b. joy has-a Happy and Happy is-a Smile, @ C.Happy has-a joy and Hapoy is-a Smile © 4. Smile is-a Happy and has-a joy Consider the following code: public class TestOverloading { int _length(String 5) { cet slengthO: © © Runtime Error © 4. chocolate enjoy Which of the following option can be best matched against the example ‘Television’? © a. Inheritance © >. Encapsulation © = Polymorphism © 4d. abstraction Consider the following listed items: A. a method declared as final B. 2 method declared as abstract C. a method declared as private Consider the following statements: Will not be available in sub classes TI. Will deny overricing the method If. Will not allow instantiating the class \Which of the following option gives the exact matches of above listed items anc statements? @ 2 A0,84m,c1 © d-Adll, Bll, Cr © «Ad, 81 Cur © 4484, cm ‘Save without submitting ‘Submit all and finish Page: (Previous) 1 2 3 4 § (Next) Consider the following code: public class Eatable ( Estable() {System.outprint("Eat"+" ");} class Chocolatet Chogolate) (Srstem-out nin Chesolate +.) Buble void eat {System outprirt(erjoy"4" public static void main(string{] args) { Eatable f = new Eatable(); FmakeChocolate(); Void makeChocolate() { (new Chocolate() <¢}).eati); ? y Which of the following option gives the valid output for the above coda? @ 2 Eat Chocolate enjoy © b. Compilation Error © Runtime Error © 4. chocolate enjoy Which of the following option can be best matched against the example Television? © @ Inheritance @ >. Encapsulation © © Polymorphism © abstraction Consider the following listed items: A.amethod declared as final d. It loads the OracleDriver class, instantistes it and registers it with DriverManager dass JDBC API allows to connect to more than one database from a Java Application simultaneously. State TRUE or FALSE. Answer: @tne OFalse Which of the following statements are true about finalize method? © @-finalize will run when an object becomes unreachable © bv finalize allows @ programmer to free memory allocated to an object © © finalize may run before or after an object is garbage collected @ 4. finalize will always run before an object is garbage collected Consider the following code: public class Eatable { Eatable() {System.out.print("eat"+" ");) dass Chocolate{ Chocelata(] {System.out.print("Chocolate"+" ");} public void eat() {System.out.print("enjoy"+" "):> } public static void main(String[] args) { Eatable { = new Eatable(); fimakeChocolate(); Void makeChocolate() { {new Chocelated ).e3t0: } Which of the following statements are true regarding try-catch-fnally? (Choose 2) vs IB 2. A catch block can have another try block nested inside b. an exception which is not handled by a catch block will be handled by subsequent catch blocks [D ¢ Finally block cannot have a try block with multiple catch blocks d. An exception which is not handled by a catch block can be hendled by writing another try catch block inside finally block Consider the following code snippet: state { rs ty Class.forName("oracle,jdbc.OracleDriver"); } catch(ClassNotFoundEsception erfe) { System. out printin(’Drver not found”); > } Which of the following statements are true regarding the above code snippet? © 2: Itloads the OracleDriver class, and instantiates a DriverManager object and retums it (© }. oracle.jdbc.OracleDriver is a DriverManager class type object ¢. It just loads the OracleDriver class, instantation happens at the time of connection oO @ 4. loads the OracleDriver cass, instartiates it and registers it with DriverMansger JDBC API allows to connect to more than one database from a Java Appiication simultaneously. State TRUE or FALSE. 7° answer Ome Zonstructors can be declared as private. State True or False. Answer: @tue OFalse srotected methods can be accessed from outside the package. State True or False. Answer: @tne OFalse Which of the following is true about packages? © .Class and Interfaces in the sub packages will be automatically available to the outer packages without using impart statement. b. Packages can contain both Classes and Interfaces c. Packages can contain only Java Source files oo@e d. Sub packages should be declared as pnvate in order to deny importing them Which of the following statements are true regarding try-catch-finally? (Choose 2) 1 2.A catch bleck can have another try block nested inside b. An exceotion which is not handled by a catch block will be handled by subsequent catch blocks 7c. Finally block cannot have a try block with mukiple catch blocks © ¢ Demands a finally block at line number 5 © 4- Shows unhandled exception type IOException at line number 4 Consider the following statements: A) Every floating-point literal is implicitly # double, not a float. B) In the declaration byte b=120; int literal 120 is implicitly converted to byte. Which of the following option is valid regarding the above statements? @ 2. Both Aanda aretrue b. Both A and 8 are false oOo ¢. Only Ais true d. only Bis true fe} Consider the fellowing Statements: Statemant A: Anonymous inner class can extend a class and implement an interface at the same time. Statemant B: Anonymous class can have their own members. Which of the following option is true regarding the above statements? @ 2.Both the statements are true © b. Statement B is true and A is false (© © Both the statements are false © 4d. Statement A is true and Bis false ‘Save without submitting Submit all and finish Page: 12 3 4 5 (Next) 75 75 75 A private method can be declared as abstract. State True or False. answer: OTe Brace Which of the following option gives the valid collection implementation ciass that implements the List interface and also provides the additional methods to cet, add and remove elements from the head and tail of the ist without specifying an index? @ 2 LinkedList b. ArrayList List oao d. Collection Consider the following code: 1 public class FinallyCatch ¢ 2 public static void main(String aras{]) { Bt { 4 throw new java.io.10Exception(); 5s} 6} 73 \ihich of the following is true regarding the above code? © @.Demands 2 finally block at line number 4 (© b. Shows unhandled exception type IOException at line number 5 @ ©. Demands a finally block at line number 5 Which of the following statements are true? (Choose 2) ® 2. Final modifier is not applicable for abstract classes I>. Private members of a class are not accessible through its object instance ©. Package level members in 4 public cless will be available to the inherited dass outside the package. IB. Static modfier is applicable only for inner classes An Annotation Type can extend another Annotation type. State True or False. Answer: Orne OFalse Consider the following variable declarations int x=100, Integer 005 Which of the following options are true regarding the above code snippet? (Cheose 3) (G3. The expressions (x < y) and (1 < y) are functionally same. b. The expression (j -i) evaluates to another Integer wrapper type object with the value 100) (= The expressions (x y) and (1 ==) are functionally same d. The expressions (x != j) and {i ~y) eveluates to the same result Page: 1 2 3 4 5 (Next) Consider the following Statements: Statement a: wait, notify and notifyall methods are not called on Thread, they are called on Object statement B: These methods can only be called from synchronized code, or an IllegalMonitorStateException will be thrown. Which of the following option is true regarding the above statements? @ 2 Statement A and B both are true © b. Statement Ais true and Bis false © ¢ Statement B is true and Ais false © 4. Statement A and B both are false Which of the following statement is true regarding the throws dedarations for overriden metheds? © 2:the overriding methad cannot re-deciara the Unchecked exceptions, that are declared by super class method. b. The overriding methed cannot dedare additional exceptions which is not declared in its super dass version. exceptions declared in the super class methods. d. When a method in the super class is declared to throw a Checked Exception, the ° @ ©. The overriding methods cannot declare to throw the Super Class types of those. ° overriding method in the sub class should also declare the same. Which of the following statements are true? (Choose 2) 1 . Final modifier is not applicable for abstract classes [J b. Private members of 2 class are not accessible through its object instance

You might also like