Template: Study Material: Insert The Details Within The
Template: Study Material: Insert The Details Within The
Key Take away from this LO1a: students should understand basic about inheritance .
Insert the details within the < quotes >
<CO>: <22412>: <Java Programming>: <Inheritance>: <LO1b>: <Study Material>
<ChetashriBhusari> <02/11/2020> <Prof.Vijay Patil>
Key Take away from this LO1b: students should understand concept of single inheritance
Key Take away from this LO: students should understand concept of multilevel inheritance
Template: Study Material
Insert the details within the < quotes >
<CO>: <22412>: <Java Programming>: <Inheritance >: <LO1d>: <Study Material>
<Chetashri Bhusari> <02/11/2020> <Prof.Vijay
Patil >
Key words Learning Objective: Diagram/
Super,Inheritance,parent Students should understand concept of hierarchical inheritance Picture
class,sub class,child class,
syntax
Examples
hierarchical
Inheritance
syntax
Key Take away from this LO: students should understand concept of hierarchical inheritance
Template: Study Material
Insert the details within the < quotes >
<CO>: <22412>: <Java Programming>: <Inheritance >: <LO2a>: <Study Material>
<Chetashri Bhusari> <04/02/2021> <Prof.Vijay Patil >
Key Take away from this LO2a: students should differentiate between method overloading and overriding concept
Template: Study Material
Insert the details within the < quotes >
<CO>: <22412>: <Java Programming>: <Inheritance >: <LO2a>: <Study Material>
<Chetashri Bhusari> <04/02/2021> <Prof.Vijay Patil >
Key Take away from this LO2a: students should differentiate between method overloading and overriding concept
Template: Study Material
Insert the details within the < quotes >
<CO>: <22412>: <Java Programming>: <Inheritance >: <LO2c>: <Study Material>
<Chetashri Bhusari> <04/02/2021> <Prof.Vijay Patil >
Concept of
static
abstract class
members
and method
Explanation of Concept: Key Definitions/
Abstract class : Formulas
► A class which is declared as abstract is known
as an abstract class.
► It can have abstract and non-abstract
methods.
► It needs to be extended and its method
implemented.
► Abstraction is a process of hiding the
implementation details and showing only
functionality to the user. Another way, it
shows only important things to the user and
hides the internal details.
► A method must be always redefined in a
subclass of an abstract class, as abstract class
does not contain method body. Thus abstract
makes overriding compulsory.
► Class containing abstract method must be
declared as a abstract.
► You cannot declare abstract constructor, and
so, objects of abstract class cannot be
instantiated.
Static members :
When a number of objects are created from
the same class, each instance has its own
copy of class variables. But this is not the case
when it is declared as static.
Static method or a variable is not attached to
a particular object, but rather to the class as
a whole. They are allocated when the class is
loaded.
If some objects have some variables which
are common, then these variables or
methods must be declared static.
To create a static variable, precede its
declaration with keyword static. Static
Solved word Problem variables need not be called on any object
Example of abstract class Example of static member:
abstract class A Int a; // normal variable static int a;
{ //static variable classs
abstract void disp(); void show() {
{ int a,b;
System.out.println(“show method is not static int c;
abstract”); }
}} class statictest
class B extends A {
{ public static void main(String args[])
void disp() {
{ s ob1=new s(); s ob2=new s(); s ob3=new s();
System.out.println(“inside class B”); }
} }
} In above program variable a and b are declared as
class test int variable whereas the variable c is declared as
{ static variable. Static variable will be common
public static void main(String args[]) between all the objects.
{
B b = new B(); b.disp();
b.show();
}
}
Output :
show method is not abstract inside class B
Link to YouTube/
Application of Concept/ Examples in real life: OER/ video
Creation of array linked list
Key Take away from this LO2c: Students should understand concept of abstract class and methods ,static members
Template: Study Material
Insert the details within the < quotes >
<CO>: <22412>: <Java Programming>: <Inheritance >: <LO3>: <Study Material>
<Chetashri Bhusari> <04/02/2021> <Prof.Vijay Patil >
Extending
Interface
Explanation of Concept: Key Definitions/
Formulas
► An interface is collection of abstract method and it
is defined much likeclass.
► Writing an interface is similar to the class, with
abstract methods and final field.
► This means that interface do not specify any code
to implement those methods & data fields
containing only constants.
► Interfaces cannot be instantiated they can be only
implemented by the classes or extended by other
Interfaces.
► Interfaces are design to support dynamic method
resolution at runtime
► The general from of interface is access interface
interface name
{
variable declaration; method declaration;
}
► Access is either public or not used when no access
specifier is included, then default access result and
interface is only available to other member of the
package in which it is declared.
► For e.g.-
public interface IF4IA
{
String Lecture=”JPR”; int benches=35;
void display();
}
Implementing Interface:
Syntax:-
class class_name implements interface
{
//body
} OR
class class_name extends class_name
Solved word Problem implements interface 1,2
Syntax:-
class class_name implements Accessing Interface Variables and Method:
interface An interface can use to declare set of constants that
{ can be used in different classes.
//body is similar to creating header files in c++ to contain a
} OR large no. of constants.
class class_name extends Such interface does not contain methods, there is
class_name no need to warry about implementing methods.
implemnts interface 1,2 All variable declared in interface must be constant.
For e.g.- inteface shape
{ multiple inheritance through interface:
public String baseclass="Shape"; It is type of interface where a derived class may
public void draw(); have more than one parent class.
} It is not possible in case of Java as you cannot have
class circle implements shape two parent classes at the parent level, instead
{ there can be one class and one interface at parent
public void draw() level to achieve multiple inheritance.
{ Interface is similar to classes but can contain final
System.out.println("Circle drawn variable and abstract methods. Interfaces can be
here"); implemented to a derived class.
}
}
Program of interface:
int x=12;
}
interface two
{
int y=10;
void display();
} Link to YouTube/
class demo implemets one, two Application of Concept/ Examples in real life: OER/ video
{ The real life example of inheritance is child and parents, all the
int a=x; int b=y; properties of father are inherited by his son.
public vioddisplay()
{
System.out.println("x in interfece
one" +x); System.out.println("y in
interfece one" +y);
System.out.println("x & y"+(x+y));
}
public void disp()
{
System.out.println("Value access
from interface one:" +a);
System.out.println("Value access
from interface two:" +b);
}
}
class multipleinterface
{
public static void main(String
args[])
{
demo d= new demo(); d.display();
d.disp();
}
}
For e.g : - interface sports
{
int sport_wt=5;
public void disp();
}
class test
{
int roll_no;
String name
int m1,m2;
test(int r, String nm, int m11,int
m12)
{
roll_no=r;
name=nm;
m1=m11;
=m12;
}
}
class result extends test
implements sports
{
result (int r, String nm, int m11,int
m12)
{
super (r,nm,m11,m12);
}
public void disp()
{
System.out.println("Roll no :
"+roll_no);
System.out.println("Name :
"+name);
System.out.println("sub1 : "+m1);
System.out.println("sub2 : "+m2);
System.out.println("sport_wt :
"+sport_wt);
int t=m1+m2+sport_wt
System.out.println("total : "+t);
}
public static void main(String
args[])
{
result r= new
result(101,"abc",75,75); r.disp();
}
}
Key Take away from this LO3: students should concept of interface
Template: Study Material
Insert the details within the < quotes >
<CO>: <22412>: <Java Programming>: <Inheritance >: <LO4>: <Study Material>
<Chetashri Bhusari> <04/02/2021> <Prof.Vijay Patil >
Key Take away from this LO3: students should concept of package
Template: Study Material
Insert the details within the < quotes >
<CO>: <22412>: <Java Programming>: <Inheritance >: <LO5>: <Study Material>
<Chetashri Bhusari> <04/02/2021> <Prof.Vijay Patil >
For eg:-
import java.util.date;
Class MyDate extends Date
{
//Body of Class
}
Solved word Problem Static Import:-
Static import is a feature that expands capabilities
Adding class to a package of import keywords. It is used to import Static
Structure:- Package p1 public member of a class.
class A Using static import, it is impossible to refer to
{ static member directly without its class name.
/body of class
} There are 2 general forms of Static import
statement.
Create a file outside of package
Import only one static member the classes from
which consists of main method particular package.
import p1.*; import static package.classname static member
class B name
{ Import static java.lang.Math.sqrt;
public static void main (String Import all static members of a class
args[]) For eg:-
Import static package.classname
{
// create object of class which is
in package
}
}
Link to YouTube/
Application of Concept/ Examples in real life: OER/ video
A real-life example is when you download a movie, song, or
game, you make a different folder for each category like
movie, song, etc. In the same way, a group of packages in java
is just like a library.
Key Take away from this LO5: students should concept of package with import and static import statement