October 18, 2024

Object Oriented Programming and Design MCQ

Object Oriented Programming
Share :

Object Oriented Programming and Design MCQ Questions & Answers


Quiz – 3

  1. Which of these is an correct way of defining generic method?
    Ans. public <T1, T2,…, Tn> name<T1, T2, …, Tn> {…}
  2. Which of the following keywords is used for throwing exception manually
    Ans. throw
  3. Which method is used to determine if two objects are equal in the Object class in Java?
    Ans. equals()


  4. A class member declared protected becomes member of subclass of which type?
    Ans. private member
  5. How can we remove an object from ArrayList?
    Ans. remove() method
  6. 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


  7. Which of these points will be valid If superclass method does not throw any exception?
    Ans. all
  8. What is the primary difference between a Map and a Set in the Java Collection Framework?
    Ans. Map is ordered, while Set is unordered
  9. Which of these methods return a class object given its name?
    Ans. findSystemClass()
  10. 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

  1. Java String object cannot be changed after creation as it is marked _____________
    Ans. Constant
  2. What is the opposite of abstract class in Java?
    Ans. Concrete class
  3. Which of these is a mechanism for naming and visibility control of a class and its content?
    Ans. Packages


  4. The keyword used to create a constant variable
    Ans. const
  5. When you pass an array to a method, the method receives _______________
    Ans. The reference of the array.
  6. Which of the following methods is/are defined in the String class for comparing the Strings?
    Ans. compareTo(String s3)


  7. What is the purpose of the substring method in Java strings?
    Ans. To extract a portion of the string
  8. In Java, what is inheritance?
    Ans. An object’s ability to accept the properties and behaviours of a parent object
  9. Which of these is a naming and visibility control mechanism of a class and its content?
    Ans. Package


  10. What is the syntax for concatenating two strings in Java?
    Ans. str1 + str2;
  11. 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.
  12. Which of these can be overloaded?
    Ans. None of the mentioned


  13. 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.
  14. 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.
  15. Which scanner class method is used to read integer value from the user
    Ans. nextInt()


  16. Which of the following is an interface in the Java Collections Framework?
    Ans. Set
  17. Which of the following statements are incorrect?
    Ans. private members of class can be inherited by a subclass, and become protected members in subclass
  18. How to sort an array?
    Ans. Arrays.sort()


  19. What is a daemon thread in Java?
    Ans. A thread that runs in the background and does not prevent the program from exiting.
  20. 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 :