MCQOPTIONS
Saved Bookmarks
This section includes 657 Mcqs, each offering curated multiple-choice questions to sharpen your Testing Subject knowledge and support exam preparation. Choose a topic below to get started.
| 1. |
JUnits are used for which type of testing? |
| A. | Unit Testing |
| B. | Integration Testing |
| C. | System Testing |
| D. | Blackbox Testing |
| Answer» B. Integration Testing | |
| 2. |
Which of the following reference types cannot be generic? |
| A. | Anonymous inner class |
| B. | Interface |
| C. | Inner class |
| D. | All of the mentioned |
| Answer» B. Interface | |
| 3. |
Which of these is an correct way of defining generic class? |
| A. | class name(T1, T2, …, Tn) { /* … */ } |
| B. | class name { /* … */ } |
| C. | class name[T1, T2, …, Tn] { /* … */ } |
| D. | class name{T1, T2, …, Tn} { /* … */ } |
| Answer» C. class name[T1, T2, …, Tn] { /* … */ } | |
| 4. |
Which of these type parameters is used for a generic class to return and accept a number? |
| A. | K |
| B. | N |
| C. | T |
| D. | V |
| Answer» C. T | |
| 5. |
Which of these type parameters is used for a generic class to return and accept any type of object? |
| A. | K |
| B. | N |
| C. | T |
| D. | V |
| Answer» D. V | |
| 6. |
Why are generics used? |
| A. | Generics make code more fast |
| B. | Generics make code more optimised and readable |
| C. | Generics add stability to your code by making more of your bugs detectable at compile time |
| D. | Generics add stability to your code by making more of your bugs detectable at run time |
| Answer» D. Generics add stability to your code by making more of your bugs detectable at run time | |
| 7. |
Which of these package is used for invoking a method remotely? |
| A. | java.rmi |
| B. | java.awt |
| C. | java.util |
| D. | java.applet |
| Answer» B. java.awt | |
| 8. |
Which of these class allows us to get real time data about private and protected member of a class? |
| A. | java.io |
| B. | GetInformation |
| C. | ReflectPermission |
| D. | MembersPermission |
| Answer» D. MembersPermission | |
| 9. |
Which of these package is used for handling security related issues in a program? |
| A. | java.security |
| B. | java.lang.security |
| C. | java.awt.image |
| D. | java.io.security |
| Answer» B. java.lang.security | |
| 10. |
Which of these package is used for analyzing code during run-time? |
| A. | java.applet |
| B. | java.awt |
| C. | java.io |
| D. | java.lang.reflect |
| Answer» E. | |
| 11. |
Which of these package is used for graphical user interface? |
| A. | java.applet |
| B. | java.awt |
| C. | java.awt.image |
| D. | java.io |
| Answer» C. java.awt.image | |
| 12. |
Can “abstract” keyword be used with constructor,Initialization Block, Instance Initialization and Static Initialization Block? |
| A. | True |
| B. | False |
| Answer» C. | |
| 13. |
What happens when we access the same variable defined in two interfaces implemented by the same class? |
| A. | Compilation failure |
| B. | Runtime Exception |
| C. | The JVM is not able to identify the correct variable |
| D. | The interfaceName.variableName needs to be defined |
| Answer» E. | |
| 14. |
What happens when constructor is defined for an interface? |
| A. | Compilation failure |
| B. | Runtime Exception |
| C. | The interface compiles successfully |
| D. | The implementing class will throw exception |
| Answer» B. Runtime Exception | |
| 15. |
What will happen if we provide concrete implementation of method in interface? |
| A. | The concrete class implementing that method need not provide implementation of that method |
| B. | Runtime exception is thrown |
| C. | Compilation failure |
| D. | Method not found exception is thrown |
| Answer» D. Method not found exception is thrown | |
| 16. |
What type of methods an interface contain by default? |
| A. | abstract |
| B. | static |
| C. | final |
| D. | private |
| Answer» B. static | |
| 17. |
What does an interface contain? |
| A. | Method definition |
| B. | Method declaration |
| C. | Method declaration and definition |
| D. | Method name |
| Answer» C. Method declaration and definition | |
| 18. |
What type of variable can be defined in an interface? |
| A. | public static |
| B. | private final |
| C. | public final |
| D. | static final |
| Answer» E. | |
| 19. |
All methods must be implemented of an interface. |
| A. | True |
| B. | False |
| Answer» B. False | |
| 20. |
Which of the following is correct way of implementing an interface A by class B? |
| A. | class B extends A{} |
| B. | class B implements A{} |
| C. | class B imports A{} |
| D. | None of the mentioned. |
| Answer» C. class B imports A{} | |
| 21. |
Which of the following access specifiers can be used for an interface? |
| A. | Protected |
| B. | Private |
| C. | Public |
| D. | Public, protected, private |
| Answer» B. Private | |
| 22. |
Which of the following is correct way of implementing an interface salary by class manager? |
| A. | class manager extends salary {} |
| B. | class manager implements salary {} |
| C. | class manager imports salary {} |
| D. | none of the mentioned |
| Answer» C. class manager imports salary {} | |
| 23. |
Which of these keywords is used by a class to use an interface defined previously? |
| A. | import |
| B. | Import |
| C. | implements |
| D. | Implements |
| Answer» D. Implements | |
| 24. |
Which of these can be used to fully abstract a class from its implementation? |
| A. | Objects |
| B. | Packages |
| C. | Interfaces |
| D. | None of the Mentioned |
| Answer» D. None of the Mentioned | |
| 25. |
Which of these keywords is used to define interfaces in Java? |
| A. | interface |
| B. | Interface |
| C. | intf |
| D. | Intf |
| Answer» B. Interface | |
| 26. |
What is the output of this program? package pkg; class output { public static void main(String args[]) { StringBuffer s1 = new StringBuffer("Hello"); s1.setCharAt(1, x); System.out.println(s1); } } |
| A. | xello |
| B. | xxxxx |
| C. | Hxllo |
| D. | Hexlo |
| Answer» D. Hexlo | |
| 27. |
What is the output of this program? package pkg; class display { int x; void show() { if (x > 1) System.out.print(x + " "); } } class packages { public static void main(String args[]) { display[] arr=new display[3]; for(int i=0;i |
| A. | 0 |
| B. | 1 |
| C. | 2 |
| D. | 0 1 2 |
| Answer» D. 0 1 2 | |
| 28. |
Which of the following package stores all the standard java classes? |
| A. | lang |
| B. | java |
| C. | util |
| D. | java.packages |
| Answer» C. util | |
| 29. |
Which of the following is incorrect statement about packages? |
| A. | Package defines a namespace in which classes are stored |
| B. | A package can contain other package within it |
| C. | Java uses file system directories to store packages |
| D. | A package can be renamed without renaming the directory in which the classes are stored |
| Answer» E. | |
| 30. |
Which of the following is correct way of importing an entire package ‘pkg’? |
| A. | import pkg. |
| B. | Import pkg. |
| C. | import pkg.* |
| D. | Import pkg.* |
| Answer» D. Import pkg.* | |
| 31. |
Which of these access specifiers can be used for a class so that it’s members can be accessed by a different class in the different package? |
| A. | Public |
| B. | Protected |
| C. | Private |
| D. | No Modifier |
| Answer» B. Protected | |
| 32. |
Which of this access specifies can be used for a class so that its members can be accessed by a different class in the same package? |
| A. | Public |
| B. | Protected |
| C. | No Modifier |
| D. | All of the mentioned |
| Answer» E. | |
| 33. |
Which of these is a mechanism for naming and visibility control of a class and its content? |
| A. | Object |
| B. | Packages |
| C. | Packages |
| D. | None of the Mentioned. |
| Answer» C. Packages | |
| 34. |
Which of these keywords is used to define packages in Java? |
| A. | pkg |
| B. | Pkg |
| C. | package |
| D. | Package |
| Answer» D. Package | |
| 35. |
Which of these package provides the ability to read and write in Zip format? |
| A. | java.lang |
| B. | java.io |
| C. | java.util.zip |
| D. | java.util.zar |
| Answer» D. java.util.zar | |
| 36. |
Which of these interfaces is implemented by TimerTask class? |
| A. | Runnable |
| B. | Thread |
| C. | Observer |
| D. | ThreadCount |
| Answer» B. Thread | |
| 37. |
Which of these classes can schedule task for execution in future? |
| A. | Thread |
| B. | Timer |
| C. | System |
| D. | System |
| Answer» C. System | |
| 38. |
Which of these methods is called when observed object has changed? |
| A. | setChanged() |
| B. | update() |
| C. | notifyObserver() |
| D. | all of the mentioned |
| Answer» E. | |
| 39. |
Which of these methods calls update() method? |
| A. | notify() |
| B. | observeObject() |
| C. | updateObserver() |
| D. | notifyObserver() |
| Answer» E. | |
| 40. |
Which of these methods is used to notify observer the change in observed object? |
| A. | update() |
| B. | notify() |
| C. | check() |
| D. | observed() |
| Answer» B. notify() | |
| 41. |
What is use of Observable class? |
| A. | It is used to create global subclasses |
| B. | It is used to create classes that other part of program can observe |
| C. | It is used to create classes that can be accessed by other parts of program |
| D. | It is used to create methods that can be accessed by other parts of program |
| Answer» C. It is used to create classes that can be accessed by other parts of program | |
| 42. |
Which of these is a method can generate a boolean output? |
| A. | retbool() |
| B. | getBool() |
| C. | nextBool() |
| D. | nextBoolean() |
| Answer» E. | |
| 43. |
Which of these method of Locale class can be used to obtain country of operation? |
| A. | getCountry() |
| B. | whichCountry() |
| C. | DisplayCountry() |
| D. | getDisplayCountry() |
| Answer» E. | |
| 44. |
Which of these class can generate pseudorandom numbers? |
| A. | Locale |
| B. | Rand |
| C. | Random |
| D. | None of the mentioned |
| Answer» D. None of the mentioned | |
| 45. |
Which of these methods is not a Locale class? |
| A. | UK |
| B. | US |
| C. | INDIA |
| D. | KOREA |
| Answer» D. KOREA | |
| 46. |
Which of these class produce objects with respect to geographical locations? |
| A. | TimeZone |
| B. | Locale |
| C. | Date |
| D. | SimpleTimeZone |
| Answer» C. Date | |
| 47. |
What is the signature of Math.random() method? |
| A. | public static double random() |
| B. | public void double random() |
| C. | public void double random() |
| D. | public void int random() |
| Answer» B. public void double random() | |
| 48. |
What would be the output of following code snippet? int a = random.nextInt(7) + 4; |
| A. | Random number between 4 to 7, including 4 and 7 |
| B. | Random number between 4 to 7, excluding 4 and 7 |
| C. | Random number between 4 to 10, excluding 4 and 10 |
| D. | Random number between 4 to 10, including 4 and 10 |
| Answer» E. | |
| 49. |
What would be the output of following code snippet? int a = random.nextInt(15) + 1; |
| A. | Random number between 1 to 15, including 1 and 15 |
| B. | Random number between 1 to 15, excluding 15 |
| C. | Random number between 1 to 15, excluding 1 |
| D. | Random number between 1 to 15, excluding 1 and 15 |
| Answer» B. Random number between 1 to 15, excluding 15 | |
| 50. |
How many bits are used for generating random numbers? |
| A. | 32 |
| B. | 64 |
| C. | 48 |
| D. | 8 |
| Answer» D. 8 | |