Вы находитесь на странице: 1из 45

Memory Management

Object - oriented programming


Object - oriented programming (OOP) is a fundamental
style of computer programming that uses “Objects” and
their interactions to design applications and computer
programs.

In OOPs, every real life object has properties and


behaviour. This feature is achieved in java through the
class and object creation. They contains properties
(variables of some type) and behaviour (methods).

OOPs provides better flexibility and compatibility for


developing large applications.
Class :
A class defines the properties and behaviour
(variables and methods) that is shared by all its
objects. It is a blue print for the creation of
 objects.

Object :
Object is the basic entity of object oriented
programming language. Class itself does nothing but
the real functionality is achieved through their
objects. Object is an instance of the class. It takes
the properties (variables) and uses the behaviour
(methods) defined in the class. 

Instance :
One can have an instance of a class or a particular
object. The instance is the actual object created at
runtime.
Object obj = new Object();
Encapsulation
Encapsulation is the process of binding together the
methods and data variables as a single entity.

This keeps both the  data and functionality code


safe  from the outside world. It hides the data within
the class and makes it available only through  the
methods. 

Java provides different accessibility scopes (public ,


protected , private , default) to hide the data from
outside.
Inheritance
Inheritance allows a class (subclass) to acquire the
properties and behavior of another class (superclass).

In java, a class can inherit only one class(superclass)


at a time but a class can have any number of
subclasses.

It helps to reuse, customize and enhance the existing


code. So it helps to write a code accurately and reduce
the development time.

Java uses extends keyword to extend a class


polymorphism
In object-oriented programming , polymorphism (from the
Greek meaning "having multiple forms") is the
characteristic of being able to assign a different
meaning or usage to something in different contexts -
specifically, to allow an entity such as a variables, a
function/method, or an object to have more than one
form. 

Overloading and Overriding are two types of


polymorphism.

Overloaded methods are methods with the same name


signature but either a different number of parameters
or different types in the parameter list

Overridden methods are methods that are redefined


within an inherited or subclass. They have the same
signature and the subclass definition is used.
Static Members
Nested Classes
System Class
Handling Strings
Wrapper Classes
 A primitive wrapper classin the
Java programming language is one of eight classes
provided in the java.lang package to provide object m
ethods for the eight primitive types. All of the primitive
wrapper classes in Java are immutable.

Wrapper classes are used to represent primitive values


when an Object is required



Primitive type Wrapper class
 byte Byte
short Short
int Integer
long Long
float Float
double Double
Char Character
boolean Boolean
Parameters passing
Packages

Вам также может понравиться