Professional Documents
Culture Documents
Daily
Daily
Data types -
1. Primitive Data type 2. Non-Primitive Data type
byte - it stores no.
int - simple no.
float - Stores decimal nos.
double - Floting type no. store
char -
boolen - True or False
short - Shortt int. store
08-03-2022
Standard Stream (in, out &
Stream - collection of data, continous flow of data, conection btw java appl &
source destination.
2 types - byte stream & chracter stream futher again divide in sub types
bufferedreader & scanner class are same but main difference is scanner has buffer
of 1kb & bufferedreader has buffer of 8kb.
bufferedreader is faster than scanner class.
in bf we read stream or text data, while in scanner we can store all primitive data
types.
class Demo
{
Public static void main(String[]args)
{
int a=10; //assign value 10 to a ident
System
}
11-03-2022
//scanner
java.util.*;
class Ar
{
public static void main(String []arg)
{
Scanner s= new Scanner (System.in);
String s =nextline
}
}
//bufferedReader
import java.io.BufferedReader;
class Ar
{
public static void main(String []arg) throws IOException
{
InputStreamReader isr= new InputStreamReader(System.in);
BufferedReader br= new BufferedReader(isr); //both are input stream
System.out.println("enter course");
String s=br.readline();
System.out.println("enter course= " +s);
}
}
--------------------------------------------------------------------------------
class Emp
{
String name;
int id;
int age;
Emp(String name, int age, int id)
{
this.age=age,
this.name=name,
this.id=id;
}
void display()
{
System.out.println("Name= " +name);
System.out.println("Age= " +age);
System.out.println("Id= " +id);
}
class Ar
{
public static void main(String []args)
{
BufferReder br = new bufferedReder(new InputStreamReader (System.in));
System.out.println("Enter Name");
String s=br.readline();
-------------------------------------------------------------------------------
String class provide formate method it gives formatted output in java. it comes
under the string class.
fro print this string 2 method
format program & printf method.
%b - true & false
%x - hexi decimal
class Ar
{
public static void main(String []args)
{
String l= "java"; // for c printf("%s", 1);
int n= 60;
String res;
System.out.println(res);
}
}
***********************************************************************************
****************************************
Methods of java
1. Constructor- it is use to initalllize to creat new object in class. class name &
method name should same.
to invoke the objecct constructor is use.
it must not have a return type.
3 types - 1. default - if we do not creat any constructor java
creates its own constructor.
2. Paramertized - Constructor Accepts args. // aa(String
A)
3. NO arg - no args is passed called. //aa()ty
4. Copy Constructor - it is use to copy same method used
in constructor.
}
public static void main (String [] args)
{
Main m = new Main();
System.out.println("the name is" + m.name);
}
}
-----------------------------------------------------------------------------------
-----------------
}
public static void main (String [] args)
{
Main m = new Main("Java");
Main m1 = new Main("Bava");
Main m2 = new Main("Mava");
System.out.println(lan+ "Programing lang");
}
}
-----------------------------------------------------------------------------------
-----------------
Default constructor - if we do not creat any constructor, java creats its own
constructor. default constructor is always 0
class Main
{
int a;
boolean b;
public static void main (String [] args)
{
Main m= nw Main();
System.out.println("value of a" = +m.a); // a=0
System.out.println("value of a" = +m.b); // b= false
}
-----------------------------------------------------------------------------------
------------------
"This" keyword
class Student
{
int roll;
String Student;
Student(int roll, String Name)
{
this.roll = roll;
this.name= name;
}
void display()
{
System.out.println("roll n0" = +roll+ "Name= " +name);
}
class Rohan
{
public static void main (String [] args) //present in only one calss. main
function name to file
{
Student s1= new Studnet (12, "AAdarsh");
Student s1= new Studnet (13, "Xyz");
s1.display();
s2.display();
}
}
***********************************************************************************
*************************************------------------------
13-03-2022
Constructor - name & class name same called constructor.
Copy Constructor - It is use to creat copy of object that has multiple fields.
2 types :
1. Shallow - makeing temporary changes call as shallow copy.
aadress are diffferent. changes not refelect in
original.
2. Deep - when the vale us assign to variable & if we take same
variable again then the value will over lap in this previous value get vanished &
updated value remains.
aadress are same. changes refelects in original.
3. Clone method - import java.lang
***********************************************************************************
**********************************
14-03-2022
// Arrays
basically it is a collection of similar datatypes /elements.
***********************************************************************************
******************************
15-03-2022
***********************************************************************************
******************************************
31-03-2022
Data types -
1. Primitive Data type 2. Non-Primitive Data type
byte - it stores no.
int - simple no.
float - Stores decimal nos.
double - Floting type no. store
char -
boolen - True or False
short - Shortt int. store
Stream - collection of data, continous flow of data, conection btw java appl &
source destination.
2 types - byte stream & chracter stream futher again divide in sub types
Public static void main define
public - asses modifire
static- keyword
void- When funcation is rturn it is accepted that no value will return.
main- funcation
[]- array
args- argument
bufferedreader & scanner class are same but main difference is scanner has buffer
of 1kb & bufferedreader has buffer of 8kb.
bufferedreader is faster than scanner class.
in bf reads stream or text data, while in scanner we can store all primitive data
types.
Main Function:
public - asses modifire
static- keyword
void- When funcation is rturn it is accepted that no value will return.
main- funcation
[]- array
args- argument
Constructor- it is use to initalllize to creat new object in class. class name &
method name should be same.
to invoke the objecct constructor is use.
it must not have a return type.
3 types - 1. default - if we do not creat any constructor java
creates its own constructor.
2. Paramertized - Constructor Accepts args. // aa(String
A)
3. NO arg - no args is passed called. //aa()ty
4. Copy Constructor - it is use to copy same method used
in constructor.
Inheritance : IT is the one in which new class is created that inheretas feature
from the already existing class.
it is of 5 types- single, multipe, multilevel, hybrid & heraarchical inheretance.
Vector - it is use to store data in form of list interface. it can grow or shrink
its size.
abstraction - hiding the implementation details & shows the funcationality to user.
- abstract class & Interface.
inheretance - to creat a new class from exesting class.
ecapsulation - hiding of information data or wrapping of data
polymorphism - it is concept in which we can perform single task in multiple ways.
exception - it is an unwaanted or unaccepted event occures during compilations. -
check & uncheck
throw - only one exception occure, thats is uncheck exception is propogated & also
it explicite the exception.
throws- multiple exception occure, thats is both check & uncheck exception are
propogated & also it implicites the exception.
super keyword -