Object Oriented Programming and Design MCQ Questions & Answers
Quiz – 3
- Which of these is an correct way of defining generic method?
Ans. public <T1, T2,…, Tn> name<T1, T2, …, Tn> {…} - Which of the following keywords is used for throwing exception manually
Ans. throw - Which method is used to determine if two objects are equal in the Object class in Java?
Ans. equals()
- A class member declared protected becomes member of subclass of which type?
Ans. private member - How can we remove an object from ArrayList?
Ans. remove() method
- What happens when a generic class is instantiated with a type parameter that does not meet the bounds specified by extends clause?
Ans. The program does not compile
- Which of these points will be valid If superclass method does not throw any exception?
Ans. all - What is the primary difference between a Map and a Set in the Java Collection Framework?
Ans. Map is ordered, while Set is unordered - Which of these methods return a class object given its name?
Ans. findSystemClass() - What happens if we put a key object in a HashMap which exists?
Ans. The new object replaces the older object
For More Updates Join Our Channels :
Quiz – 2
- Java String object cannot be changed after creation as it is marked _____________
Ans. Constant - What is the opposite of abstract class in Java?
Ans. Concrete class - Which of these is a mechanism for naming and visibility control of a class and its content?
Ans. Packages
- The keyword used to create a constant variable
Ans. const - When you pass an array to a method, the method receives _______________
Ans. The reference of the array.
- Which of the following methods is/are defined in the String class for comparing the Strings?
Ans. compareTo(String s3)
- What is the purpose of the substring method in Java strings?
Ans. To extract a portion of the string - In Java, what is inheritance?
Ans. An object’s ability to accept the properties and behaviours of a parent object - Which of these is a naming and visibility control mechanism of a class and its content?
Ans. Package
- What is the syntax for concatenating two strings in Java?
Ans. str1 + str2;
- Which of the following is true about a thread’s priority in Java?
Ans. A thread with a higher priority will always execute before a thread with a lower priority. - Which of these can be overloaded?
Ans. None of the mentioned
- What is the difference between an ArrayList and a LinkedList in Java?
Ans. An ArrayList and a LinkedList are both equally efficient for adding, removing, and accessing elements. - if there is an abstract method in a class, then which of the following is/are Not true.
Ans. No object of the class can be created. - Which scanner class method is used to read integer value from the user
Ans. nextInt()
- Which of the following is an interface in the Java Collections Framework?
Ans. Set - Which of the following statements are incorrect?
Ans. private members of class can be inherited by a subclass, and become protected members in subclass - How to sort an array?
Ans. Arrays.sort()
- What is a daemon thread in Java?
Ans. A thread that runs in the background and does not prevent the program from exiting. - Name the keyword that makes a variable belong to a class, rather than being defined for each instance of the class.
Ans. static
For More Updates Join Our Channels :