Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Other

OOPs in Java

Rating
-
Sold
-
Pages
15
Uploaded on
18-03-2023
Written in
2022/2023

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 cover all the key concepts and best practices for developing robust, scalable, and maintainable software using Java. Whether you are a beginner learning the basics of OOP or an experienced developer looking to deepen your knowledge of Java programming, these notes are an indispensable resource. With practical examples, clear explanations, and helpful tips and tricks, these notes will help you master the art of OOP in Java and take your programming skills to the next level. Don't miss out on this opportunity to improve your knowledge and expertise - get these notes today!

Show more Read less
Institution
Course

Content preview

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

Written for

Course

Document information

Uploaded on
March 18, 2023
Number of pages
15
Written in
2022/2023
Type
OTHER
Person
Unknown

Subjects

$3.99
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
shriharik

Get to know the seller

Seller avatar
shriharik PACE
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
3 year
Number of followers
0
Documents
2
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions