Professional Documents
Culture Documents
(Lec-13) Java SE
(Lec-13) Java SE
(Lec-13) Java SE
(CORE JAVA)
LECTURE-13
Today’s Agenda
• Thus we can say that a class represents the data type and object
represents a kind of variable of that data type
2. Polymorphism
3. Inheritance
Abstraction and Encapsulation
Poly- Many
Morph- Forms
Reusability
Extensibility
• Syntax :-
class <class name>
Optional
{
<access modifier> <data type> <variable name>= value;
-
-
-
<access modifier> <return type> <method name>(arguments)
{
// Method body
}
}
• Example :-
1000
class Student 0 roll
{
1000 ‘\n’ grade
int roll;
s
char grade; 0.0 per
float per;
}
class UseStudent
{
public static void main(String [ ] args)
{
Student s;
s=new Student();
}
Continued Program
class UseStduent
{
public static void main(String [ ] args)
{
Student s;
s=new Student( );
Does this code violate the
s.roll=10;
rules of Object Oriented
s.grade=‘A’; Programming ???
s.per=66.5f;
It violates the rule of
S.O.P(“Roll is ”+s.roll); Encapsulation.
S.O.P(“Grade is ”+s.grade);
S.O.P(“Percentage is ”+s.per);
}
Access Modifiers
• public
• private
• protected
• default