Analysis of Object-Oriented Programming Concepts in Java: A Report

Verified

Added on  2025/04/25

|11
|1117
|415
AI Summary
Desklib provides past papers and solved assignments for students. This report analyzes Java's object-oriented programming concepts.
Document Page
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
Contents
Introduction:...............................................................................................................................2
Object Oriented Concepts:.........................................................................................................3
Abstraction:............................................................................................................................3
Inheritance:.............................................................................................................................3
Single Inheritance:.................................................................................................................3
Multilevel Inheritance:...........................................................................................................3
Hierarchical Inheritance:........................................................................................................4
Encapsulation:........................................................................................................................5
Polymorphism:.......................................................................................................................5
Method Overriding:................................................................................................................5
Method Overloading:.............................................................................................................5
Conclusion..................................................................................................................................7
References..................................................................................................................................8
Document Page
Table of figures
Figure 1Single Inheritance.........................................................................................................5
Figure 2 Snippet for single inheritance.....................................................................................5
Figure 3 Multi-Level Inheritance...............................................................................................6
Figure 4 Snippet for Multi-Level inheritance............................................................................6
Figure 5 Hierarchical Inheritance...............................................................................................7
Figure 6 Snippet of Multi-Level Inheritance code.....................................................................7
Figure 7: Method Overloading...................................................................................................8
Document Page
Introduction:
This report will be useful for providing a brief overview of approaches which is being used in
the program. The program is built on JAVA which is an Object Oriented Programming
Language and program also uses various OOP’s concept. JAVA doesn’t allow multiple
inheritances which make JAVA not a pure Object Oriented Programming language
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
Object-Oriented Concepts:
OOP’s concepts which are mainly used in JAVA are abstraction, inheritance, polymorphism,
and Encapsulation. Let discuss them in details:
Abstraction:
Abstraction means hiding the necessary details which are not required by the user. In simple
words, we can say hiding confidential data which is not required by the user. In JAVA
abstraction means implementing simple things like classes and their object and variables
which are required multiple times. JAVA runs on classes. (OOP Concepts, 2019)
Inheritance:
Inheritance means working in a form of hierarchical form. Classes can inherit the properties
of their successor classes and can implement them in their class and use their properties.
There are various types of inheritance available in JAVA:
Single Inheritance:
It means that a single class can inherit the property of their parent class. It can only inherit the
property of their parent class. Only there is a single level in case of single inheritance.
Figure 1Single Inheritance
In the above image class B is the child class and class A is the parent class. Class B is
inheriting the property of class A.
Figure 2 Snippet for single inheritance
Document Page
Above image will give a brief snippet about code which is being used in JAVA for single
level inheritance. To inherit the property of parent class “extends” keyword is being used.
Class B is inheriting the properties of class A using extends keyword. (GeeksforGeeks, 2019)
Multilevel Inheritance:
In this type of inheritance, there are multiple levels which can inherit the property from their
successor class and there are multiple levels of inheritance.
Figure 3 Multi-Level Inheritance
From the above image it can be stated that class C is inherting the property of class B and
class B is inheriting the property of class A.
Figure 4 Snippet for Multi-Level inheritance
In this snippet image class B extending the property of class A and class C is extending
property of class B.
Hierarchical Inheritance:
It means that multiple class can inherit the property from the same parent class. This is
known as hierarchical inheritance.
Document Page
Figure 5 Hierarchical Inheritance
In this image class B and Class C is inheriting the property of Class A.
Figure 6 Snippet of Multi-Level Inheritance code
In the above snippet of code, class B is extends property of class A and class C will also be
extending the property of class A.
JAVA doesn’t support multi-level inheritance which states that a child class can inherit
properties from two different parent class.
Encapsulation:
Encapsulation is another property of OOP’s Concept, which means that wrapping up of data
in a single unit. The class can be an example of Encapsulation it means that data members
and method are wrapped up in a single unit. JAVA runs on classes and to run a program in
java class is mandatory.
Polymorphism:
In JAVA polymorphism works with reference to a parent class by affecting object which is
being present in the child class. There are two examples of polymorphism in JAVA i.e
method overloading and method overriding.
Method Overriding:
The overriding of the method means that using methods in a different scope. Example using
the same method in the base class as well as parent class can form method overriding.
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
Method Overloading:
It means that calling the same method with a different number of parameters and with
different attributes is known as method overloading. (OOP Concepts, 2019)
Figure 7: Method Overloading
(Source: TechBytes, 2019)
An approach which is being used in this program is object-oriented programming concepts
like classes and it is used throughout the program. The program is written in JAVA which is
an OOP’s programming Language but it not purest OOP’s programming language. Choices
and approaches which are being thought are being implemented properly and correct output
is being generated by the program.
If any other program is being given which is based on the same concept. The same concept or
approaches is being used in any other program like recycling machine or ticket machine.
Brief Explanation of Program:
This program is about managing a vending machine which has products like chips, chocolate
bars, coco cola, and two other products is available in the vending machine. Arrays of snacks
are being created in class PrintHelllo which is used for processing and storage of information
provided in the brief. Price and denomination of coins which is being taken by the vending
machine are being available in the form of an array of double data types. Various other
Document Page
variables are being defined in the class PrintHello which should be used throughout the
program. The main class is being used for inputting the values which the user wants to enter
in the vending machine. The menu of the vending machine is providing a top of ‘10000 steps
healthy snacks’ after that menu option is printed in below page of the vending machine. After
taking all inputs processing is being done according to the information provided in brief.
After that bill is being printed after the user will say no. Total bill is being available in the
end of the program for a particular user. (GeeksforGeeks, 2019)
Document Page
Conclusion
In this report designing of the program is being discussed and approaches which is taken into
account where object oriented programming concepts is being used throughout the program.
Approaches used in this project are discussed and correctness of the program is also
discussed. Future programs which can also be made with this approaches is also discussed.
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
References
OOP Concepts (2019). What Are OOP Concepts in Java? 4 Primary Concepts. [online] Stackify.
Available at: https://stackify.com/oops-concepts-in-java/ [Accessed 29 Mar. 2019].
GeeksforGeeks. (2019). Basic Concepts of Object Oriented Programming using C++ -
GeeksforGeeks. [online] Available at: https://www.geeksforgeeks.org/basic-concepts-of-object-
oriented-programming-using-c/ [Accessed 29 Mar. 2019].
TechBytes. (2019). Method overloading in Java Part 2. [online] Available at:
http://mundrisoft.com/tech-bytes/method-overloading-in-java-part-2/ [Accessed 29 Mar. 2019].
chevron_up_icon
1 out of 11
circle_padding
hide_on_mobile
zoom_out_icon
[object Object]