๐Ÿงพ Java OOP Practical Exam โ€“ Set 2

โฑ๏ธ Exam Details

  • Time: 2 Hours
  • Maximum Marks: 50

๐Ÿ“Œ Q1. Class & Object + Constructor (10 Marks)

Create a class Book with:

  • Data members: title, author, price

Requirements:

  • Create a parameterized constructor to initialize values
  • Create a method displayDetails()
  • Create object in main() and display details

๐Ÿ‘‰ Concepts tested:

  • Class & Object
  • Constructor initialization

๐Ÿ“Œ Q2. Inheritance & Method Overriding (10 Marks)

Create a class Person:

  • Method: showDetails()

Create a subclass Student:

  • Add: rollNumber
  • Override showDetails()

Requirements:

  • Display student-specific details
  • Use overridden method

๐Ÿ‘‰ Concepts tested:

  • Inheritance
  • Method overriding

๐Ÿ“Œ Q3. Encapsulation + Getter/Setter (10 Marks)

Create a class BankAccount:

  • Private variables:
    • accountNumber
    • balance

Requirements:

  • Provide getter and setter methods
  • Create object and display details using getters

๐Ÿ‘‰ Concepts tested:

  • Encapsulation
  • Data hiding

๐Ÿ“Œ Q4. Abstract Class / Interface (10 Marks)

Create an abstract class Vehicle:

  • Abstract method: start()
  • Concrete method: fuelType()

Create subclasses:

  • PetrolVehicle
  • ElectricVehicle

Requirements:

  • Implement abstract method
  • Call both methods

๐Ÿ‘‰ Concepts tested:

  • Abstraction
  • Abstract class

๐Ÿ“Œ Q5. Polymorphism + Dynamic Method Dispatch (10 Marks)

Create a class Shape:

  • Method: draw()

Create subclasses:

  • Circle
  • Square

Requirements:

  • Override draw()
  • Use parent class reference to call methods

๐Ÿ‘‰ Concepts tested:

  • Runtime polymorphism
  • Dynamic method dispatch

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *