0% found this document useful (0 votes)
13 views7 pages

Abc

Uploaded by

Murali Vijay
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)
13 views7 pages

Abc

Uploaded by

Murali Vijay
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
You are on page 1/ 7

static :

static is keyword

which can used with variable,method,block.constructor,class

static in same class we can access directly or with class name

All static member will get stored inside static pool or class area.

syntax:

className.VariableName;

className.methodName();

Example:

static class public Student{

static age=20;

static void regno(){

s.o.p()

p.s.v.m(String[] agrs){

Student.age();

s.o.p(+age);

Student.regno();

method Overloading:

process of multiple method with same name but different in parameter is known as method
overloading.

Rules:

1.there should be change in no's parameter

2.there should be change in datatype.


3.there should be change in sequence of order to achieve method overloading.

Ex:

public class Car{

void buy(){

s.o.pln();

void buy(String product){

s.o.pln();

void buy(int cost, double salary, String product){

s.o.pln();

main(){

Car c=new Car();

c.buy();

c.buy("20");

c.buy(25,5.0,"murali");

static and nonstaic diff

access in same class access in different class stored loc no’s of copy

static directly or class name class name static pool, class area 1

non static object creation object creation heap area multiple object
depends on no’s of objects

Array:

1.Array is a container to store group of data or elements(group of same datatype).

2. Array is fixed size(size is fixed cannot change).

3.Array is a homogenous in nature(datatype should be same we cannot change and alter).

4.Array index start with 0 because 0 is the first positive number.

Array declaration:

Int[] a;
Array creation:

a=new Int[5];

Array declaration & creation;

Int[] a= new int[6];

Array initialization:

A[2]=20;

Array declaration & array initialization;

Int[] a={20,30,40,50};

Inheritance:

Inheritance process of one class acquiring another class properties is known as inheritance.

2.to achieve inheritance we can use extends keyword.

3.sharing properties of a class is known as parent class, super class, base class

4.Aquiring properties of a class is known as sub class, child class, derived class.

5.inheritance is also refer as Is-A Relationship.

Types:

1.single level

2.multi-level

3.hierachical

4.hybrid

5.multiple inheritance

1.single inheritance:

Is a combination of one sub class and one super class is known as

2.multi level inheritance:

Is a combination of multiple super class and multiple sub class

3.hieracical inheritance;

Is a combination of one super have multiple sub class is know as

4.hybrid inheritance:

Is a combination of multiple and hieracical inheriatnce

5.multiple inheritance:
Is combination of one sub class and multiple super class is known as

In java multiple inheritance doesnot supported.

Ex;

Class Car{

Class student extends Car{

Class employee extends Student{

Mainclass:

Class Student1{

Main(){

Car c=new Car();

s.o.pln();

s.o.pln();

2.Constructor Overloading.

Process of having multiple constructor with same name but different in parameter is known as
constructor overloading.

Rules:

1.there should be change in no's parameter

2.there should be change in datatype.

3.there should be change in sequence of order to achieve method overloading.

Constructor overloading example:

Class car{

Int cost;

String brand;

Double interest;

Car(Int cost, String brand, Double interest){


This.cost=cost;

This.brand=brand;

This.interest=interest;

Car(double cost){

s.o.pln();

Car(int cost){

s.o.pln();

Main(){

Car c=new Car();

Method Overriding:

Is process of a inheriting method have same name and same datatype is know as method Overriding
but different in implementation is known as

Is process of a inheriting method but change in implementation

Before inheriting we write annotation means method override.

Example:

Class car{

Void buy(){

s.o.pln(“old bike”);

Class engine extends Car{

@Overriding

Void buy(){

s.o.pln(“modified bike”);

Main(){

} }
Super:

1.super is a Keyword.

2.which is use to access super class member or different class we can access using super keyword.

Syntax:

Super.variableName;

Super.methodName();

Constructor chaining;

The process of one constructor to calling another constructor is know as Constructor chaining.

To achieve constructor chaining in ways

1.this calling statement

2.super calling statement

Is-A relationship(Inheritance).

1.Implicitly super calling statement :

If super class is non parameterized constructor the sub class constructor call implicitly.

2.Explicitly super calling statement:

If super is parameterized sub class constructor call explicitly.

EX:

Advantage:

1.code redundancy is avoided.

2.code reusability is increased.

You might also like