0% found this document useful (0 votes)
12 views2 pages

Experiment No 4

The document outlines an experiment focused on implementing inheritance and object-oriented programming concepts in Java. It includes objectives, background information on key terms, practical programming questions, and a quiz on related topics. The aim is to enhance software design and development skills through the understanding of class hierarchies and code reuse.

Uploaded by

heetkarena123
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views2 pages

Experiment No 4

The document outlines an experiment focused on implementing inheritance and object-oriented programming concepts in Java. It includes objectives, background information on key terms, practical programming questions, and a quiz on related topics. The aim is to enhance software design and development skills through the understanding of class hierarchies and code reuse.

Uploaded by

heetkarena123
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Experiment No: 4

AIM: To implement inheritance and object-oriented concepts.

Date:

CO mapped: CO-2

Objectives:

a) To master the fundamental principles of inheritance and object-oriented concepts,


enabling the design and development of efficient, maintainable, and scalable software
solutions by leveraging the power of class hierarchies and code reuse.
b) Implementing these basic object-oriented concepts in your software development
practices will help you create more structured, maintainable, and reusable code, which
is essential for building robust and scalable software systems.

Background:
Object means a real-world entity such as a pen, chair, table, computer, watch, etc. Object-
Oriented Programming is a methodology or paradigm to design a program using classes and
objects. Inheritance in Java is a mechanism in which one object acquires all the properties
and behaviors of a parent object. It is an important part of OOPs (Object Oriented
programming system). The idea behind inheritance in Java is that you can create new classes
that are built upon existing classes. When you inherit from an existing class, you can reuse
methods and fields of the parent class. Moreover, you can add new methods and fields in
your current class also.
Terms used in Inheritance

● Class: A class is a group of objects which have common properties. It is a template or


blueprint from which objects are created.
● Sub Class/Child Class: Subclass is a class that inherits the other class. It is also called
a derived class, extended class, or child class.
● Super Class/Parent Class: Superclass is the class from where a subclass inherits the
features. It is also called a base class or a parent class.
● Reusability: As the name specifies, reusability is a mechanism that facilitates you to
reuse the fields and methods of the existing class when you create a new class. You
can use the same fields and methods already defined in the previous class.

Practical questions:
1. A set of 5 words (strings) will be taken as command line arguments. Write a program
to reverse each word and check whether it is palindrome or not using method.
2. Define the class BankAccount to represent an account we open with bank. Define the
subclasses SavingAccount and FixedDepositAccount. Implement the operations like
openAccount(), deposit(), checkBalance(), withdraw() and calInterest() for these
classes.
3. Write a program that finds area of any shape by overloading area () method for
Square, Rectangle, Triangle and Square.
4. Write a program that finds Volume of any shape by overloading volume () method for
Cube, Rectangular Cube and Sphere.
5. Write a Program to maintain employee’s information. Program should illustrate
Inheritance concept. (Use your imagination to create class or subclass used for
employee).
6. Create a base class Shape. Use this class to store two double type values that could be
used to compute area of any shape. Derive two specific classes called Triangle and
Rectangle from the base shape. Add to the base a member function getdata() to
initialize base class data member and another member function display_area() to
compute and display the area of figures. (Use Method Overriding).

Observations: Put Output of the program

Conclusion:

Quiz:
1. What is inheritance in java? Explain different types of inheritance with proper example.
2. Explain the use of final and Super keyword in JAVA
3. Define polymorphism with its need.
4. Explain about Encapsulation, Abstraction.

Suggested Reference:

1. https://www.tutorialspoint.com/java/
2. https://www.geeksforgeeks.org/
3. https://www.w3schools.com/java/
4. https://www.javatpoint.com/

You might also like