OOPS Using Java
Assignment 1
Java Fundamentals
1. History of Java
○ Explain the origin of Java.
○ Who developed Java and in which year?
○ Why was Java initially called Oak?
○ Mention key milestones in Java’s evolution.
2. Object-Oriented Programming (OOP)
○ Define Object-Oriented Programming.
○ List and explain the four main concepts of OOP with examples.
3. OOP vs POP
○ Differentiate between Object-Oriented Programming (OOP) and Procedure-
Oriented Programming (POP) in a tabular format.
4. Concepts of OOP
○ Explain the following with examples:
a) Class and Object
b) Encapsulation
c) Inheritance
d) Polymorphism
e) Abstraction
5. Features of Java
○ List at least 8 important features of Java and explain all n detail.
6. Data Types in Java
○ Describe the different data types in Java with examples.
○ Mention the size and default value of each primitive data type.
7. Command Line Arguments
○ What are command line arguments in Java?
○ Write the syntax of the main() method to accept command line arguments.
8. Polymorphism
What is method overloading in Java? How it is achieved? Explain with program
What is method overriding? How is it achieved ? Explain with program.
9. Ways to Create Strings
● Explain the two main ways to create strings in Java:
a) Using string literals
b) Using the new keyword
● Write the difference between these approaches in terms of memory allocation (String
Constant Pool vs Heap).
● Explain String and StringBuffer class in Java. Write a program to implement 5 methods
of each class.
10. Inheritance
● Describe the types of inheritance supported by Java (Single, Multilevel, Hierarchical,
Hybrid, Multiple).
● Why does Java not support multiple inheritance through classes?
● Provide small code snippets for at least 3 types.
11. Java Keywords
● Explain the usage of the following keywords with examples:
a) this
b) final
c) static
d) super
Programs
1. Write a Java program to accept three integers from the command line and display their
sum and average
2. Create a class Car with attributes: model, color, year, and price. Initialize the
values using parameterized constructors. Include a method to display the instance
variables and a method to check if the car is older than 5 years. In main method, create
2 objects & call the methods.
3. Create a class Student with attributes: rollNumber, name, marks1, marks2,
marks3. Use constructors to initialize the values. Write methods to calculate the total
marks and percentage.In main method, create 2 objects & call the methods.
4. Write a program to demonstrate Hierarchical Inheritance (e.g., Shape → Circle,
Rectangle).
5. Write a program using super keyword to access the parent class constructor and
method.
6. Create a class BankAccount with attributes: accountNumber, accountHolderName,
and balance.
Provide methods to:
● deposit(amount) – add money to balance.
● withdraw(amount) – deduct money if sufficient balance exists.
● display() – show account details.
Create 2 objects in main method and call the functions.
7. Answer the following scenario-based questions:
a) A university wants to manage Staff and TeachingStaff with common and specialized
properties. Which type of inheritance is best suited? Justify.
b) Design a class hierarchy for Vehicles, where Car and Bike share properties of a
Vehicle. Which type of inheritance will you choose?
c) If a class Shape has a method draw() and subclasses Circle and Rectangle
override it, explain which concept of inheritance/polymorphism is applied.