




Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
OOP concepts in Java are the main ideas behind Java's Object Oriented Programming. They are an abstraction, encapsulation, inheritance, and polymorphism. ... Basically, Java OOP concepts let us create working methods and variables, then re-use all or part of them without compromising security.
Typology: Thesis
1 / 8
This page cannot be seen from the preview
Don't miss anything!





Encapsulation & Abstraction
All programs are made up of two fundamental elements: Data Information that the program holds Functions Perform actions on and manipulate the data Users should not be allowed to “mess around” with the data Avoid Encapsulation keeps data and functions safe from outside interference and manipulation. Exposes only the interfaces and hides the details Done through the use of public, private and protected keywords Also known as data hiding
class Box { private double length; public double getVolume (void) { return length * length * length; } public double Length{ get {return length;} set {length = value;} } }; //end class Box Abstractio n Encapsulat ion
Notice the first method’s name in the previous example? getVolume() What does the word ‘get’ signify? Also notice how this function has no input and only a return type This type of function is called an “Accessor” OR a “Getter” function. As it is obvious from the name, it is used to access or get a value
As programs become larger with multiple functions and classes, it becomes difficult to maintain a single file for everything. Solution: divide your code into multiple files that are easier to maintain.
Write a class named “Pizza” which has the following attributes: Size Toppings (list of different ingredients) Crust (type) Price Create the class diagram for the class “Pizza” Write the code for the class and test it. How will you make sure the data is properly abstracted and encapsulated?