Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
20 views6 pages

Class 11

Uploaded by

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

Class 11

Uploaded by

Sohel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

JAVA BASICS

Abstraction:-
Abstraction is an oops concept where programmer hide the implementation code and show the end
functionality to the end user.
So Abstraction means hiding the implementation code and displaying the end result to the user.

for example :- An mobile phone call, when we receive a phone call we cannot see the backend operation happening.

Encapsulation:-
Binding or wrapping the code and data together into a single unit is known as encapsulation. A java class is
the example of encapsulation.
for example :- An Capsule hold medicine in it.
An java class is perfect example of encapsulation as all the methods and data members are encapsulated in class.

***Note:-Abstract is a keyword, used with class or method to declare them incomplete.


Abstraction is an OOPs concept
Casting in Java:-
Casting is a process where one type of information is converted into another type of information.

Casting

Primitive Non Primitive


Casting Casting

Implicite Boolean Upcasting DownCasting

Expilcite
Primitive Casting:- (Type Casting)
In Primitive casting one type of datatype is converted into another type. Primitive casting takes place
between data type.
Two types of primitive casting:-
1). Implicite Casting.
2). Explicite Casting.

1). Implicite Casting:-


In implicite casting lower type of datatype information is changed to higher type datatype information.
No data loss occurs in this as we convert a smaller data type to higher type. This casting is also known as widening

byte short int double

Example :- int a =10;


double r = a;

Implicite casting as here int type of information stored in variable a is converted into double type.
Explicite Casting:-
In Explicite casting higher type of datatype information is lower type datatype information.
Data occurs in this as we convert higher datatype to lower.
This type of casting is known as narrowing.

byte short int double

Example:- double a = 13.35;


int r = (int) a;

Boolean Casting :- not supported in java.


Non Primitive Casting:-
In non primitive casting one type of class information is converted to another type.

Two Types:-
1). Upcasting
2).DownCasting.

1).Upcasting:-
In upcasting the property of subclass are given to super class.Property of subclass is upcasted in super
class.

• For upcasting inheritance must take place.


• In upcasting only those properties are upcasted which are inherited from super class.
• Method hiding is possible in Upcasting.

Syntax:-
SuperClassName variable = new SubclassName();

You might also like