These notes provide a concise yet comprehensive overview of Object-Oriented Programming (OOP) concepts in Java, one of the most popular programming languages in use today. From the fundamentals of classes, objects, and inheritance to advanced topics such as polymorphism and abstraction, these notes...
Object-Oriented Programming is a methodology or paradigm to design a
program using classes and objects. It simplifies the software development
and maintenance by providing some concepts defined below :
Class is a user-defined data type which defines its properties and its
functions. Class is the only logical representation of the data. For
example, Human being is a class. The body parts of a human being are its
properties, and the actions performed by the body parts are known as
functions. The class does not occupy any memory space till the time an
object is instantiated.
Object is a run-time entity. It is an instance of the class. An object can
represent a person, place or any other item. An object can operate on
both data members and member functions.
Example 1:
class Student {
String name;
int age;
public void getInfo() {
System.out.println("The name of this Student is " + this.name);
System.out.println("The age of this Student is " + this.age);
}
}
public class OOPS {
public static void main(String args[]) {
Student s1 = new Student();
s1.name = "Aman";
s1.age = 24;
s1.getInfo();
Note : When an object is created using a new keyword, then space is
allocated for the variable in a heap, and the starting address is stored in
the stack memory.
‘this’ keyword : ‘this’ keyword in Java that refers to the current
instance of the class. In OOPS it is used to:
1. pass the current object as a parameter to another
method
2. refer to the current class instance variable
The benefits of buying summaries with Stuvia:
Guaranteed quality through customer reviews
Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.
Quick and easy check-out
You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.
Focus on what matters
Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!
Frequently asked questions
What do I get when I buy this document?
You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.
Satisfaction guarantee: how does it work?
Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.
Who am I buying these notes from?
Stuvia is a marketplace, so you are not buying this document from us, but from seller shriharik. Stuvia facilitates payment to the seller.
Will I be stuck with a subscription?
No, you only buy these notes for $3.49. You're not tied to anything after your purchase.