Académique Documents
Professionnel Documents
Culture Documents
Submitted to:
Mr Amit Monga
Submitted by:
Lavish Bansal
1969-1973
Denis Ritche
A T & T Bell Lab
Windows
C++
1975-1984
Bjarne
StrausStrup
Windows
JAVA
1991-1995
James Gosling
Sun Microsystems
Oracle
FEATURES OF OOPS
It has 4 main features:>Inheritance
>Encapsulation
>Polymorphism
>Abstraction
What is JAVA ?
A general purpose object-oriented Programing
language.
Write Once Run Anywhere (WORA).
Designed for easy web/internet applications
Widespread acceptance
It is case sensitive language.
It is developed and deployed.
DATATYPE
Basically Data type is which type of value store
in variable.
SYNTAX <datatype> <variablename>;
Int age;
It is of 2 types:
Primitive(Pre defined) and Reference(User
defined).
ARRAYS
Array is a collection of variables of same
datatype.
SYNTAX <datatype> [] <array name> = new
<datatype> [];
Example:- int [] arr=new int [5];
PACKAGES
Packages are collection of classes or it act as a
container for different classes.
How to create a package?
PACKAGE <package name>;
class abc
{
};
CONSTRUCTOR
Class name and constructor name must be same.
It do not have any return type.
It is called when we create object of class.
It is used to initialise and store the variable.
Class hh
{
int a;
hh()
{a=10;
}
INHERITANCE
It is basically reusability ,like parent->child ,
super class->sub class.
SYNTAX :- extends <class name>
Type of inheritance:>single
>multilevel
>multiple
class person
{
String firstname;
String lastname;
person(String fname,String lname)
{firstname=fname;
lastname=lname;
}
void display()
{System.out.println("person:");
System.out.println("firstname:"+firstname);
System.out.println("lastname:"+lastname);
}
}
class student extends person
{
int id;
String standard;
String instructor;
student(String fname,String lname,int nld,String stnd,String instr)
{
super(fname,lname);
id=nld;
standard=stnd;
instructor=instr;
}
void display()
{
System.out.println("student:");
super.display();
System.out.println("id:"+id);
System.out.println("standard:"+standard);
System.out.println("instructor:"+instructor);
}
}
class teacher extends person
{
String mainsubject;
String type;
int salary;
type=stype;
}
void display()
{
System.out.println("teacher:");
super.display();
System.out.println("mainsubject:"+mainsubject);
System.out.println("salary:"+salary);
System.out.println("type:"+type);
}
}
class inheritancedemo
{
public static void main(String arr[])
{
person pobj=new person("rayan","miller");
student sobj=new student("jacob","smith",1,"1-b","roma");
teacher tobj=new teacher("daniel","mart","english",6000,"primary teacher");
pobj.display();
sobj.display();
tobj.display();
}}
ABSTRACT CLASS
Abstract is a keyword used along with classes
and methods.
In this we only declare the methods , we
define these methods in there child class.
Abstract class use only abstract methods.
Example:-
Abstract class dd
{
public abstract void a();
public abstract void b();
}
class s extends dd
{
public void a()
{
int a=10;
System.out.println(a);
}
public void b()
{int bb=10;
System.out.println(bb);
public static void main(String arr[])
{
s.b=new s();
b.a();
b.bb();
}}
INTERFACE
It is used for multiple inheritance.
In interface we only declare the methods , we define
these methods in there child class.
Example:Interface kk
{
}
Interface gg
{
}
Class s implements kk,gg
EXCEPTION HANDLING
Basically we have 3 types of errors:>Syntax error- occurs at compilation time
>Logical error- can occur at compile time or run
time
>Runtime error- basically unexpected
So to resolve this we use exception handling.
It has 3 blocks:> Try used where exception can occur.
> Catch used to handle the exception.
>Finally always run.
class ex
{
public static void main(String[]arr)
{
try
{
String aa=arr[0];
int a=Integer.parseInt(arr[1]);
int b=Integer.parseInt(arr[2]);
int c=a/b;
System.out.println(c);
System.out.println(aa);
System.out.println(b);
}
catch(Exception e)
{
System.out.println(e);
}
GUI
Defined as graphical user interface.
Till now we had used it on black command
window but from now we will se how it will
work and we will visualise it .
Example:- import java. Awt.*;
Awt=abstract window toolkit
The child class of awt is swingx
Example:-import javax.swing.*;
CONSTRUCTION OF FRAME
Import javax.swing.*;
Class cont
{
Jframe f;
Jbutton b;
cont()
{
f=new Jframe (welcome);
b=new Jbutton(submit);
}
Public void aa()
{
f.add(b);
f.setSize(100,100);
f.setvisible(true);
Public static void main(String arrr[])
{cont v=new cont();
v.aa();
}}
Thank You