Here are 15 multiple choice questions at the university level about object- oriented programming in Java:
General
1. What are the four pillars of object-oriented programming?
o (A) Abstraction, encapsulation, inheritance, and polymorphism.
o (B) Classes, objects, methods, and fields.
o (C) Public, private, protected, and default access modifiers.
o (D) None of the above.
2. What is the difference between a class and an object in Java?
o (A) A class is a blueprint for creating objects, while an object is an instance of a class.
o (B) A class is a logical entity, while an object is a physical entity.
o (C) A class can be inherited, while an object cannot.
o (D) All of the above.
Java Specifics
3. What is the difference between a static method and a non-static method in Java?
o (A) A static method can be called without creating an instance of the class, while a non-static method cannot.
o (B) A static method does not have access to the non-static members of the class, while a non-static method does.
o (C) A static method is typically used for utility functions, while a non-static method is typically used for operations specific to the class.
o (D) All of the above.
4. What is the difference between a superclass and a subclass in Java?
o (A) A superclass is a more general class, while a subclass is a more specific class.
o (B) A superclass is the parent class, while a subclass is the child class.
o (C) A superclass can be inherited, while a subclass cannot.
o (D) All of the above.
5. What is the purpose of the interface keyword in Java?
o (A) To define a contract that a class must implement.
o (B) To create a new type of object.
o (C) To forward declare a class or function.
o (D) All of the above.
Challenge Questions
6. Discuss the difference between method overriding and method overloading in Java.
7. Explain how to use interfaces to achieve loose coupling in Java.
8. Discuss the different types of exceptions in Java and how to handle them effectively.
9. Explain how to use generics in Java to write more reusable code.
10.Discuss the benefits of using multithreading in Java.
I hope these questions are helpful!