Java Lect - Basic
Java Lect - Basic
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:
Adding new data and function is not easy. Adding new data and function is easy.
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:
2. Code Reusability
3. Easy Management
4. Maintenance
5. Abstraction
6. Polymorphism
Disadvantages of 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
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:
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