java Summer training
presentation
Submit to:Mr.Jitendra Rauthan Submit by Prabhakar Koranga
content
What is java
History of java
Application of java
Features of java
Java simple program
What is inheritance
Why java is not support multiple inheritance
What is interface and use of interface
Multiple inheritance in Java by interface
What is java
Java is programming language and a platform.
Java runs on variety of platforms.
Javais high level and object-oriented
language.
Javais simple and secured programming
language.
History of java
The small team of sun engineers called Green Team
Start java project in 1991.
Originally designed for small, embedded systems in
electronic appliances like set-top boxes.
The language ,initially called Oak.
In 1995, Oak was renamed as "Java” .
Java is an island of Indonesia where first coffee was
produced (called java coffee).
Application of java
Desktop applications
Web applications
Enterprise applications
Mobile
Games
FEATURES OF JAVA
Simple
Object-oriented
Platform independent
Secured
Portable
Multithreaded
Java simple program
Class A Class A
{ {
Public static void main(String arg[]) static public void main(String f[])
{ {
System.out.println(“hello java”); System.out.println(“hello java”);
}} }}
Introduction multiple inheritance
Inheritance in java is a mechanism in which one object acquires all the properties and
behaviors of parent object.
The idea behind inheritance in java is that you can create new classes that are built upon
existing classes. When you inherit from an existing class, you can reuse methods and fields of
parent class, and you can add new methods and fields also.
Inheritance represents the IS-A relationship, also known as parent-child relationship.
Inheritance is use For Method Overriding and Code Reusability.
Syntax of Java Inheritance
class Subclass-name extends Superclass-name
{
//methods and fields
}
Why java is not support multiple inheritance
When a class extends multiple classes i.e. known as multiple inheritance.
On the basis of class, there can be three types of inheritance in java:
single, multilevel and hierarchical.
In java programming, multiple and hybrid inheritance is supported through
interface only.
Multiple inheritance is not supported in java through class.
To reduce the complexity and simplify the language, multiple inheritance is not supported in java.
For example we have A, B and C are three classes. The C class inherits A and B classes. If A and B classes have same method and
you call it from child class object, there will be ambiguity to call method of A or B class.
Since compile time errors are better than runtime errors, java renders compile time error if you inherit 2 classes. So whether
you have same method or different, there will be compile time error now.
class A{
void msg(){
System.out.println("Hello");}
}
class B{
void msg()
{
System.out.println("Welcome");}
}
class C extends A
{
Public Static void main(String args[]){
C obj=new C();
obj.msg();
}
}
Interface
An interface in java is a blueprint of a class. It has static constants
and abstract methods only.
The interface in java is a mechanism to achieve fully abstraction.
There can be only abstract methods in the java interface not method
body.
It is used to achieve fully abstraction and multiple inheritance in
Java.
Java Interface also represents IS-A relationship.
It cannot be instantiated just like abstract class
Why we use interface
There are mainly three reasons to use interface.
They are given below.
It is used to achieve fully abstraction.
By interface, we can support the functionality
of multiple inheritance.
It can be used to achieve loose coupling.
The java compiler adds public and abstract keywords before the
interface method and public, static and final keywords before data
members.
Multiple inheritance in Java by interface
If a class implements multiple interfaces, or an interface
extends multiple interfaces i.e. known as multiple
inheritance.
interface Printable
{
void print();
}
interface dis
{
void print();
}
class Test implements Printable,dis
{
public void print()
{
System.out.println("Hello");
}
public static void main(String args[])
{
Test obj = new Test();
obj.print();
}
}
Thanku for watching my
presentation