0% found this document useful (0 votes)
16 views

Java Lect - Basic

Uploaded by

Aritra Samanta
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

Java Lect - Basic

Uploaded by

Aritra Samanta
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 12

Course Name - Object Oriented Programming using Java

Object Oriented Programming concepts - Difference between OOP and


other conventional programming – advantages and disadvantages. Class,
object, Method.

Presented By
Dr. Sudipta Sahana
Associate Professor
Dept. of CSE
UEM - Kolkata
Topic of Interest
 Object-oriented programming: concept
 Difference between Conventional Programming and Object Oriented
Programming
 Advantages of OOP
 Disadvantages of OOP
 Object
 Class
 Method
Object Oriented Programming:
Object-Oriented Programming or OOPs refers to languages that uses objects in programming.
Object-oriented programming aims to implement real-world entities like inheritance, hiding,
polymorphism etc in programming. The main aim of OOP is to bind together the data and the
methods that operate on them so that no other part of the code can access this data except that
method.
Difference between Conventional Programming and
Object Oriented Programming:

CONVENTIONAL PROGRAMMING OBJECT ORIENTED PROGRAMMING


.In conventional programming, program is divided In object oriented programming, program is divided
into small parts called functions. into small parts called objects.
Conventional programming follows top down Object oriented programming follows bottom up
approach. approach.
There is no access specifier in conventional Object oriented programming have access specifiers
programming. like private, public, protected etc.

Adding new data and function is not easy. Adding new data and function is easy.

Conventional programming does not have any


Object oriented programming provides data hiding so
proper way for hiding data so it is less secure.
it is more secure.

In conventional programming, overloading is not Overloading is possible in object oriented


possible. programming.

Examples: C, FORTRAN, Pascal, Basic etc. Examples: C++, Java, Python, C# etc.
Advantages of OOP
Due to the various problems faced by the procedural languages, this concept was introduced.
Therefore, it has a number of advantages over the procedural programming. OOP is still being
widely used; new languages also adopt these OOP concepts. Let us discuss some the
advantages of the Object-oriented programming:

1. Real Word Entities

2. Code Reusability

3. Easy Management

4. Maintenance

5. Abstraction

6. Polymorphism
Disadvantages of OOP

Despite of having so many advantages it also has disadvantages.

1. Proper planning and designing is required in OOP

2. OOP programs design are tricky

3. Large size & Many Instructions

4. Classes tends to be over generalised


Class in OOP

A class is a group of objects which have common properties. It is a template or blueprint from
which objects are created. It is a logical entity. It can't be physical. A class in Java can
contain:A class represents a collection of objects having same characteristic properties that
exhibit common behavior.
It gives the blueprint or description of the objects that can be created from it. Creation of an
object as a member of a class is called instantiation. Thus, object is an instance of a class
How to Create a Class

To create a class, use the keyword class

Create a class named "MyClass" with a variable x:

public class MyClass {


int x = 5;
}
Object

An object is a real-world element in an object–oriented environment that may have a


physical or a conceptual existence.

Objects can be modelled according to the needs of the application. An object may have a
physical existence, like a customer, a car, etc.; or an intangible conceptual existence, like
a project, a process, etc.
How to create an Object

 In Java, an object is created from a class. We have already created the class
named MyClass, so now we can use this to create objects.
 To create an object of MyClass, specify the class name, followed by the object name,
and use the keyword new:
Example
Create an object called "myObj" and print the value of x:

public class MyClass {


int x = 5;
public static void main(String[] args)
{ MyClass myObj = new MyClass();
System.out.println(myObj.x);
}
}
Method

A method is a collection of statements that perform some specific task and return result to the
caller. A method can perform some specific task without returning anything. Methods allow us
to reuse the code without retyping the code. In Java, every method must be part of some class
which is different from languages like C, C++ and Python.
Methods are time savers and help us to reuse the code without retyping the code.
Thank
You

You might also like