Objects and Classes II

Objects and Classes II

Objects and Classes in Programming, Constructors, Encapsulation and Access Modifiers, Static Members, Inheritance and Polymorphism, Advanced Topics: Anonymous Objects and Inner Classes, Object Cloning, Real-world Object Representation, E-commerce System

1 / 10

Which of the following is true about inheritance?

2 / 10

What does method overriding require?

3 / 10

What is an anonymous object in Java?

4 / 10

Which of the following is true about inner classes?

5 / 10

What does the clone() method in Java do?

6 / 10

Which interface must a class implement to support cloning?

7 / 10

A company is designing a library management system. Which of the following best represents the relationship between objects and classes?

8 / 10

In a banking system, a BankAccount class has fields accountNumber, accountHolder, and balance. Which approach ensures that the balance cannot be directly modified by the user, but can be updated via methods?

9 / 10

In an e-commerce system, you are creating a Product class with the following requirements:

  • Each product has a productID, name, and price.
  • Products should automatically generate a productID when created.
    Which approach is the most efficient to handle this?

10 / 10

In a mobile application, a User class has methods login() and logout(). You also need a PremiumUser class with an additional accessPremiumContent() method. Which design principle is best suited for this scenario?

Your score is

Scroll to Top