100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
OOPs in Java $3.49   Add to cart

Other

OOPs in Java

 5 views  0 purchase
  • Course
  • Institution

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...

[Show more]

Preview 2 out of 15  pages

  • March 18, 2023
  • 15
  • 2022/2023
  • Other
  • Unknown
avatar-seller
OBJECT ORIENTED PROGRAMMING SYSTEMS
JAVA


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();


Student s2 = new Student();

, s2.name = "Shradha";
s2.age = 22;
s2.getInfo();
}
}



Example 2:
class Pen {
String color;

public void printColor() {
System.out.println("The color of this Pen is " + this.color);
}
}

public class OOPS {
public static void main(String args[]) {
Pen p1 = new Pen();
p1.color = blue;

Pen p2 = new Pen();
p2.color = black;

Pen p3 = new Pen();
p3.color = red;

p1.printColor();
p2.printColor();
p3.printColor();
}
}



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

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

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

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.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

80435 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy study notes for 14 years now

Start selling
$3.49
  • (0)
  Add to cart