0% found this document useful (0 votes)
10 views3 pages

Java OOP Concepts and Implementation

Uploaded by

Rohan Kadu
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views3 pages

Java OOP Concepts and Implementation

Uploaded by

Rohan Kadu
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

class a{

void display(){
[Link]("This is a A class");
}
}

class b extends a{
void display(){
[Link]("This is a B class");
}
}
class c extends a{
void display(){
[Link]("This is a C class");
}
}

public class Interfaces implements car,person{


public static void main(String[] args) {

}
public void start(){//implementing interface method should be
public
[Link]("start");
}
public void walk(){
[Link]("walk");
}
}

interface car{//intefrace cannot be marked as protected


void start(); // by deafult it public abstarct rehta he or
interface method static kabhi nahi ho skata
}

//java mutiple inheritance ko support nay karta so usko tackle karne ke


liye interfce used karte suppose interface person
interface person{
void walk();
}
class Shape{
void name(){
[Link]("This is Shape class");
}
void f1(){
[Link]("this is f1");
}
public Shape(){
[Link]("superrrrrrrrrrrrrrrrr");
}
double area(double len , double bre){
return len*bre;
}
}

class Rectangle extends Shape{


public Rectangle(){
super();
}
void name(){
[Link]();
[Link]("this is Ractangle class");
}
int area(int len , int bre){
return len*bre;
}
// double area(double len , double bre){
// return len*bre;
// }
// void f1(){
// [Link]("this is child f1");
// }
}

public class oops {


public static void main(String[] args) {
Shape sh = new Rectangle();
[Link](); // run time polymorphism;
sh.f1();//this object can access function of base class if in
case any of the method that oveeried in subclass then that method will
call
//compile time polymorphism

Rectangle rec = new Rectangle();


rec.f1();// pehle khud ke class me dekhega nahi he toh parent
class me dekhega
[Link]("binds to Double area
function :"+[Link](55.5,65));
[Link]("binds to int area function :"+[Link](1,
2));

}
}

//Encalpuslation : means bundling of data members and methods is know


as encapsulation example is class ,protection ke liye used hota he aur
acces modifiers used karte he
//abstraction : means hids the implenation and shows only functionality
to user ex car
//inheritance : when child class inherits the property of parent class
is known as inheritance
//types - single level , mutilevel , herirchial , mutiple suport nay
karta java but c++ karta he matlab ek child class mutiple parent class
nay ho sakte , hybrid
//polymorphism
// above code

// access modifiers : public means we can access class field or method


anywhere in pacakage or outside the pacakage
// private means we can it within class only
// protected means we can acees it in derived class in same package or
outside the package
// default we can access it within packakge only

// Static : we dont need to create class objectb ot access it we can


access it by [Link] if you calling static method from non static
method then you have to call using [Link] and if you calling from
static method to non static then you have to create object , if static
to static or non static to non static use only function name
//super(age ,name ) when you create child class object and you want to
call constructor of parent class
//and you can used when the method is overriden in subclass you can
call method in parent class
// transient : the a variable is declared as transient. This means that
it will not be serialized when the Employee objecthet is written to
file [Link]. When the object is read from the file, the a
variable will be initialized to its default value, which is 0.

You might also like