OOps Intro (1)
OOps Intro (1)
The lang that supports following oop's features is called as object oriented
programming lang.
1. Abstraction
2. Encapsulation
3. Inheritance
4. Polymorphsim
Abstraction :
Hiding unnecessary details from end user and provide them with the set of
interfaces to consume the functionality is known as abstraction.
Encapsulation :
Keeping the data and functions together in a single wrapper or unit known as class,
to provide data security.
Inheritance :
Reusing the functionalites of existing class in a new class by establishing parent
child relation between classes is known as inheritance.
Polymorphism :
Behaving in different ways depending upon the input receive is known as
polymorphism.
OR
Whenver the input changes the op also changes.
Class :
class Person
{
}
Object :
As,
Class is also a datatype, so above rule applies to a class also.
It means if we want to use a class we need to create a copy of that class known as
object. Using the object we can consume the members present in the class.
Object syntax:
<Classname> <objname> = new <classname>([ <arg1,arg2,...> ]);
CLASS Code :
package pack_class;
import java.util.Scanner;
package pack_class;
}
}
TODO:
class Calc
{
private int num1,num2;
class Program
{
main()
{
}
}
class Rectangle
{
private double lenght,breadth;
}
}
class Program
{
p s v m(String ...)
{