SlideShare a Scribd company logo
Program 1 
Program: WAP in java to print “Hello World”. 
class Hello 
{ 
public static void main(String args[ ]) 
{ 
System.out.println("Hello World"); 
} 
}
Java Programs Lab File
Program 2 
Program: WAP in java to implement programs to define a class and 
instantiate its object. 
import java.io.*; 
class Student 
{ 
int sid; 
String sname,sadr,sfname,smname; 
BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); 
public void input()throws IOException 
{ 
System.out.println("please input sid,name,fname and mname"); 
sid=Integer.parseInt(br.readLine()); 
sname=br.readLine(); 
sfname=br.readLine(); 
smname=br.readLine(); 
} 
public void display() 
{ 
System.out.println("Student's id="+sid); 
System.out.println("Student's name="+sname); 
System.out.println("Student's father name="+sfname); 
System.out.println("Student's mother name="+smname); 
} 
} 
class object 
{ 
public static void main(String args[ ])throws IOException 
{ 
Student s=new Student(); 
s.input(); 
s.display(); 
} 
}
Java Programs Lab File
Program 3 
Program: WAP in java to implement constructor and method overloading. 
class demo 
{ 
int area(int a) 
{ 
return(a*a); 
} 
int area(int a,int b) 
{ 
return(a*b); 
} 
double area(double a) 
{ 
return(3.14*a*a); 
} 
} 
class room 
{ 
public static void main(String args[]) 
{ 
demo d=new demo(); 
System.out.println("Area of square="+d.area(5)); 
System.out.println("Area of rectangle="+d.area(6,4)); 
System.out.println("Area of circle="+d.area(1.25)); 
} 
}
Java Programs Lab File
Program 4 
Program: WAP in java to implement Command line argument. 
class ComLineTest 
{ 
public static void main(String args[ ]) 
{ 
int count,i=0; 
String s; 
count=args.length; 
System.out.println("Number of arguments="+count); 
while(i<count) 
{ 
s=args[i]; 
i=i+1; 
System.out.println(i+":"+"java is"+s+"!"); 
} 
} 
}
Java Programs Lab File
Program 5 
Program: WAP in java to implement String class. 
class abc 
{ 
public static void main(String args[]) 
{ 
int n,i,j; 
String s=new String("manju"); 
System.out.println(" Length of String="+s.length()); 
int l=s.length(); 
for(i=0;i<l;i++) 
{ 
for(j=0;j<=i;j++) 
System.out.print(s.charAt(j)); 
System.out.print("n"); 
} 
} 
}
Java Programs Lab File
Program 6 
Program: WAP in java to implement 2D-Arrays. 
import java .io.*; 
class element 
{ 
public static void main(String args[ ])throws IOException 
{ 
int a[ ][ ]=new int[3][3]; 
int i,j; 
BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); 
System.out.println("please input nine elements for matrices"); 
for(i=0;i<3;i++) 
for(j=0;j<3;j++) 
a[i ][ j]=Integer.parseInt(br.readLine()); 
System.out.println("the matrices"); 
for(i=0;i<3;i++) 
{ 
for(j=0;j<3;j++) 
System.out.println(a[i][j]+"t"); 
System.out.println("n"); 
} 
} 
}
Java Programs Lab File
Program 7 
Program: WAP in java to implement Multi-level inheritance. 
import java.util.*; 
class multilevel 
{ 
static Scanner sc=new Scanner(System.in); 
static class A 
{ 
int a1,a2; 
void getdata() 
{ 
System.out.println("Enter the value of a1 is:"); 
a1=sc.nextInt(); 
System.out.println("Enter the value of a2 is:"); 
a2=sc.nextInt(); 
} 
void putdata() 
{ 
System.out.println("n The value of a1 is:"+ a1 +" and a2:"+ a2); 
} 
} 
static class B extends A 
{ 
int b1; 
void add() 
{ 
b1=a1+a2; 
System.out.println("n The Sum is:"+b1); 
} 
} 
static class C extends B 
{ 
int c1; 
void mul() 
{ 
c1=b1*a1; 
System.out.println("The product is :"+c1); 
} 
} 
public static void main(String args[]) 
{ 
C obj=new C(); 
obj.getdata(); 
obj.add(); 
obj.mul(); 
} 
}
Java Programs Lab File
Program 8 
Program: WAP in java implement the use of interface. 
interface my 
{ 
public void show(); 
} 
class demo implements my 
{ 
public void show() 
{ 
System.out.println("This is interface program"); 
} 
} 
class sks 
{ 
public static void main(String args[]) 
{ 
demo d=new demo(); 
d.show(); 
} 
}
Java Programs Lab File
Program 9 
Program: WAP in java implement method overriding. 
class One 
{ 
void display() 
{ 
System.out.println("I am class One"); 
} 
} 
class Two extends One 
{ 
void display() 
{ 
System.out.println("I am class Two"); 
} 
} 
class Overriding 
{ 
void display() 
{ 
System.out.println("I am from class override"); 
} 
public static void main(String args[]) 
{ 
Overriding obj=new Overriding(); 
obj.display(); 
Two t=new Two(); 
t.display(); 
} 
}
Java Programs Lab File
Program 10 
Program: WAP in java to implement Multithreading. 
class A extends Thread 
{ 
public void run() 
{ 
for(int i=1;i<5;i++) 
{ 
System.out.println("t from Thread A:"+i); 
} 
System.out.println("Exit from Thread A"); 
} 
} 
class B extends Thread 
{ 
public void run() 
{ 
for(int j=0;j<5;j++) 
{ 
System.out.println("t from Thread B:"+j); 
} 
System.out.println("Exit from Thread B"); 
} 
} 
class threadtest 
{ 
public static void main(String args[]) 
{ 
A ob=new A(); 
B ob1=new B(); 
ob.start(); 
ob1.start(); 
} 
}
Java Programs Lab File
Program 11 
Program: WAP in java to implement Exception Handling. 
class Error 
{ 
public static void main(String args[]) 
{ 
int a=10,b=5,c=5,x,y; 
try 
{ 
x=a/b-c; 
} 
catch(Exception e) 
{} 
{ 
System.out.println("Division by zero"); 
} 
y=a/b+c; 
System.out.println("y="+y); 
} 
}
Java Programs Lab File
Program 12 
Program: WAP in java to implement User-defined and pre-defined packages. 
package package1; 
public class A 
{ 
public void display() 
{ 
System.out.println("This is class A"); 
} 
} 
import package1.A; 
class Packagetest1 
{ 
public static void main(String args[]) 
{ 
A obj=new A(); 
obj.display(); 
} 
}
Java Programs Lab File
Program 13 
Program: WAP in java to implement applet using Graphics class. 
import java.awt.*; 
import java.applet.*; 
import java.net.*; 
public class star extends Applet 
{ 
public void paint(Graphics g) 
{ 
g.setColor(Color.green); 
int x[ ]={80,100,150,120,150,80,0,30,0,50}; 
int y[ ]={10,40,40,70,120,90,120,70,40,40}; 
g.drawPolygon(x,y,10); 
g.fillPolygon(x,y,10); 
} 
} 
/*<applet code="star.class"width=500 height=500></applet>*/
Java Programs Lab File
Program 14 
Program: WAP in java to implement the use of I/O Streams. 
import java.io.*; 
class First 
{ 
public static InputStreamReader input=new InputStreamReader(System.in); 
public static BufferedReader keyboardInput=new BufferedReader(input); 
static PrintWriter screenOutput=new PrintWriter(System.out,true); 
public static void main(String[] args)throws IOException 
{ 
String name; 
screenOutput.print("What is your name?"); 
screenOutput.flush(); 
name=keyboardInput.readLine(); 
screenOutput.print("nHello"+name); 
screenOutput.println("java is based on independent platform"); 
} 
}
Java Programs Lab File
Program 15 
Program: WAP in java to implement swing program. 
import javax.swing.*; 
class program extends JFrame 
{ 
program() 
{ 
setTitle("first form"); 
setSize(300,300); 
setVisible(true); 
} 
} 
class form 
{ 
public static void main (String args[ ]) 
{ 
program p=new program(); 
} 
}
Java Programs Lab File
Ad

More Related Content

What's hot (20)

Infix prefix postfix
Infix prefix postfixInfix prefix postfix
Infix prefix postfix
Self-Employed
 
Infix to-postfix examples
Infix to-postfix examplesInfix to-postfix examples
Infix to-postfix examples
mua99
 
Java programming lab manual
Java programming lab manualJava programming lab manual
Java programming lab manual
sameer farooq
 
heap Sort Algorithm
heap  Sort Algorithmheap  Sort Algorithm
heap Sort Algorithm
Lemia Algmri
 
Final JAVA Practical of BCA SEM-5.
Final JAVA Practical of BCA SEM-5.Final JAVA Practical of BCA SEM-5.
Final JAVA Practical of BCA SEM-5.
Nishan Barot
 
Applications of stack
Applications of stackApplications of stack
Applications of stack
eShikshak
 
Inheritance in c++
Inheritance in c++Inheritance in c++
Inheritance in c++
Vishal Patil
 
Runnable interface.34
Runnable interface.34Runnable interface.34
Runnable interface.34
myrajendra
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
RahulAnanda1
 
Stack using Array
Stack using ArrayStack using Array
Stack using Array
Sayantan Sur
 
Java Inheritance
Java InheritanceJava Inheritance
Java Inheritance
VINOTH R
 
Templates in C++
Templates in C++Templates in C++
Templates in C++
Tech_MX
 
Stack data structure
Stack data structureStack data structure
Stack data structure
Tech_MX
 
Lab report for Prolog program in artificial intelligence.
Lab report for Prolog program in artificial intelligence.Lab report for Prolog program in artificial intelligence.
Lab report for Prolog program in artificial intelligence.
Alamgir Hossain
 
Class template
Class templateClass template
Class template
Kousalya M
 
Java practical
Java practicalJava practical
Java practical
shweta-sharma99
 
Data Structures Practical File
Data Structures Practical File Data Structures Practical File
Data Structures Practical File
Harjinder Singh
 
Strings in C language
Strings in C languageStrings in C language
Strings in C language
P M Patil
 
Unary operator overloading
Unary operator overloadingUnary operator overloading
Unary operator overloading
Md. Ashraful Islam
 
class and objects
class and objectsclass and objects
class and objects
Payel Guria
 
Infix prefix postfix
Infix prefix postfixInfix prefix postfix
Infix prefix postfix
Self-Employed
 
Infix to-postfix examples
Infix to-postfix examplesInfix to-postfix examples
Infix to-postfix examples
mua99
 
Java programming lab manual
Java programming lab manualJava programming lab manual
Java programming lab manual
sameer farooq
 
heap Sort Algorithm
heap  Sort Algorithmheap  Sort Algorithm
heap Sort Algorithm
Lemia Algmri
 
Final JAVA Practical of BCA SEM-5.
Final JAVA Practical of BCA SEM-5.Final JAVA Practical of BCA SEM-5.
Final JAVA Practical of BCA SEM-5.
Nishan Barot
 
Applications of stack
Applications of stackApplications of stack
Applications of stack
eShikshak
 
Inheritance in c++
Inheritance in c++Inheritance in c++
Inheritance in c++
Vishal Patil
 
Runnable interface.34
Runnable interface.34Runnable interface.34
Runnable interface.34
myrajendra
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
RahulAnanda1
 
Java Inheritance
Java InheritanceJava Inheritance
Java Inheritance
VINOTH R
 
Templates in C++
Templates in C++Templates in C++
Templates in C++
Tech_MX
 
Stack data structure
Stack data structureStack data structure
Stack data structure
Tech_MX
 
Lab report for Prolog program in artificial intelligence.
Lab report for Prolog program in artificial intelligence.Lab report for Prolog program in artificial intelligence.
Lab report for Prolog program in artificial intelligence.
Alamgir Hossain
 
Class template
Class templateClass template
Class template
Kousalya M
 
Data Structures Practical File
Data Structures Practical File Data Structures Practical File
Data Structures Practical File
Harjinder Singh
 
Strings in C language
Strings in C languageStrings in C language
Strings in C language
P M Patil
 
class and objects
class and objectsclass and objects
class and objects
Payel Guria
 

Similar to Java Programs Lab File (20)

Java programs
Java programsJava programs
Java programs
Dr.M.Karthika parthasarathy
 
Core java
Core javaCore java
Core java
SRM Institute of Science & Technology, Tiruchirappalli
 
Java Programs
Java ProgramsJava Programs
Java Programs
vvpadhu
 
Internet and Web Technology (CLASS-16) [Basic Elements of Java Program] | NIC...
Internet and Web Technology (CLASS-16) [Basic Elements of Java Program] | NIC...Internet and Web Technology (CLASS-16) [Basic Elements of Java Program] | NIC...
Internet and Web Technology (CLASS-16) [Basic Elements of Java Program] | NIC...
Ayes Chinmay
 
Core java pract_sem iii
Core java pract_sem iiiCore java pract_sem iii
Core java pract_sem iii
Niraj Bharambe
 
Introduction to-java
Introduction to-javaIntroduction to-java
Introduction to-java
QUAID-E-AWAM UNIVERSITY OF ENGINEERING, SCIENCE & TECHNOLOGY, NAWABSHAH, SINDH, PAKISTAN
 
Object oriented programming la bmanual jntu
Object oriented programming la bmanual jntuObject oriented programming la bmanual jntu
Object oriented programming la bmanual jntu
Khurshid Asghar
 
java input & output statements
 java input & output statements java input & output statements
java input & output statements
VigneshManikandan11
 
Object Oriented Solved Practice Programs C++ Exams
Object Oriented Solved Practice Programs C++ ExamsObject Oriented Solved Practice Programs C++ Exams
Object Oriented Solved Practice Programs C++ Exams
MuhammadTalha436
 
Java Practical File Diploma
Java Practical File DiplomaJava Practical File Diploma
Java Practical File Diploma
mustkeem khan
 
Java and j2ee_lab-manual
Java and j2ee_lab-manualJava and j2ee_lab-manual
Java and j2ee_lab-manual
hanumanthu mothukuru
 
Java oops features
Java oops featuresJava oops features
Java oops features
VigneshManikandan11
 
JAVAPGMS.docx
JAVAPGMS.docxJAVAPGMS.docx
JAVAPGMS.docx
Mgm Mallikarjun
 
Java practical
Java practicalJava practical
Java practical
william otto
 
Java 5 and 6 New Features
Java 5 and 6 New FeaturesJava 5 and 6 New Features
Java 5 and 6 New Features
Jussi Pohjolainen
 
Java doc Pr ITM2
Java doc Pr ITM2Java doc Pr ITM2
Java doc Pr ITM2
Aram Mohammed
 
Java ppt Gandhi Ravi ([email protected])
Java ppt  Gandhi Ravi  (gandhiri@gmail.com)Java ppt  Gandhi Ravi  (gandhiri@gmail.com)
Java ppt Gandhi Ravi ([email protected])
Gandhi Ravi
 
Java Language fundamental
Java Language fundamentalJava Language fundamental
Java Language fundamental
Infoviaan Technologies
 
Java final lab
Java final labJava final lab
Java final lab
Vivek Kumar Sinha
 
Sam wd programs
Sam wd programsSam wd programs
Sam wd programs
Soumya Behera
 
Ad

More from Kandarp Tiwari (13)

Artificial Intelligence Lab File
Artificial Intelligence Lab FileArtificial Intelligence Lab File
Artificial Intelligence Lab File
Kandarp Tiwari
 
Speed Detecting Camera by Kandarp Tiwari
Speed Detecting Camera by Kandarp TiwariSpeed Detecting Camera by Kandarp Tiwari
Speed Detecting Camera by Kandarp Tiwari
Kandarp Tiwari
 
Speed Detecting Camera by Kandarp Tiwari
Speed Detecting Camera by Kandarp TiwariSpeed Detecting Camera by Kandarp Tiwari
Speed Detecting Camera by Kandarp Tiwari
Kandarp Tiwari
 
Web Technology Lab File
Web Technology Lab FileWeb Technology Lab File
Web Technology Lab File
Kandarp Tiwari
 
Web Technology Front Page
Web Technology Front PageWeb Technology Front Page
Web Technology Front Page
Kandarp Tiwari
 
Web technology
Web technologyWeb technology
Web technology
Kandarp Tiwari
 
Compiler design front page
Compiler design front pageCompiler design front page
Compiler design front page
Kandarp Tiwari
 
Computer Networks Front Page
Computer Networks Front PageComputer Networks Front Page
Computer Networks Front Page
Kandarp Tiwari
 
Computer Networks Lab File
Computer Networks Lab FileComputer Networks Lab File
Computer Networks Lab File
Kandarp Tiwari
 
Compiler Design Lab File
Compiler Design Lab FileCompiler Design Lab File
Compiler Design Lab File
Kandarp Tiwari
 
Os lab file c programs
Os lab file c programsOs lab file c programs
Os lab file c programs
Kandarp Tiwari
 
DAA Lab File C Programs
DAA Lab File C ProgramsDAA Lab File C Programs
DAA Lab File C Programs
Kandarp Tiwari
 
Computer Graphics Lab File C Programs
Computer Graphics Lab File C ProgramsComputer Graphics Lab File C Programs
Computer Graphics Lab File C Programs
Kandarp Tiwari
 
Artificial Intelligence Lab File
Artificial Intelligence Lab FileArtificial Intelligence Lab File
Artificial Intelligence Lab File
Kandarp Tiwari
 
Speed Detecting Camera by Kandarp Tiwari
Speed Detecting Camera by Kandarp TiwariSpeed Detecting Camera by Kandarp Tiwari
Speed Detecting Camera by Kandarp Tiwari
Kandarp Tiwari
 
Speed Detecting Camera by Kandarp Tiwari
Speed Detecting Camera by Kandarp TiwariSpeed Detecting Camera by Kandarp Tiwari
Speed Detecting Camera by Kandarp Tiwari
Kandarp Tiwari
 
Web Technology Lab File
Web Technology Lab FileWeb Technology Lab File
Web Technology Lab File
Kandarp Tiwari
 
Web Technology Front Page
Web Technology Front PageWeb Technology Front Page
Web Technology Front Page
Kandarp Tiwari
 
Compiler design front page
Compiler design front pageCompiler design front page
Compiler design front page
Kandarp Tiwari
 
Computer Networks Front Page
Computer Networks Front PageComputer Networks Front Page
Computer Networks Front Page
Kandarp Tiwari
 
Computer Networks Lab File
Computer Networks Lab FileComputer Networks Lab File
Computer Networks Lab File
Kandarp Tiwari
 
Compiler Design Lab File
Compiler Design Lab FileCompiler Design Lab File
Compiler Design Lab File
Kandarp Tiwari
 
Os lab file c programs
Os lab file c programsOs lab file c programs
Os lab file c programs
Kandarp Tiwari
 
DAA Lab File C Programs
DAA Lab File C ProgramsDAA Lab File C Programs
DAA Lab File C Programs
Kandarp Tiwari
 
Computer Graphics Lab File C Programs
Computer Graphics Lab File C ProgramsComputer Graphics Lab File C Programs
Computer Graphics Lab File C Programs
Kandarp Tiwari
 
Ad

Recently uploaded (20)

five-year-soluhhhhhhhhhhhhhhhhhtions.pdf
five-year-soluhhhhhhhhhhhhhhhhhtions.pdffive-year-soluhhhhhhhhhhhhhhhhhtions.pdf
five-year-soluhhhhhhhhhhhhhhhhhtions.pdf
AdityaSharma944496
 
fluke dealers in bangalore..............
fluke dealers in bangalore..............fluke dealers in bangalore..............
fluke dealers in bangalore..............
Haresh Vaswani
 
introduction to machine learining for beginers
introduction to machine learining for beginersintroduction to machine learining for beginers
introduction to machine learining for beginers
JoydebSheet
 
Mathematical foundation machine learning.pdf
Mathematical foundation machine learning.pdfMathematical foundation machine learning.pdf
Mathematical foundation machine learning.pdf
TalhaShahid49
 
Degree_of_Automation.pdf for Instrumentation and industrial specialist
Degree_of_Automation.pdf for  Instrumentation  and industrial specialistDegree_of_Automation.pdf for  Instrumentation  and industrial specialist
Degree_of_Automation.pdf for Instrumentation and industrial specialist
shreyabhosale19
 
AI-assisted Software Testing (3-hours tutorial)
AI-assisted Software Testing (3-hours tutorial)AI-assisted Software Testing (3-hours tutorial)
AI-assisted Software Testing (3-hours tutorial)
Vəhid Gəruslu
 
π0.5: a Vision-Language-Action Model with Open-World Generalization
π0.5: a Vision-Language-Action Model with Open-World Generalizationπ0.5: a Vision-Language-Action Model with Open-World Generalization
π0.5: a Vision-Language-Action Model with Open-World Generalization
NABLAS株式会社
 
Artificial Intelligence (AI) basics.pptx
Artificial Intelligence (AI) basics.pptxArtificial Intelligence (AI) basics.pptx
Artificial Intelligence (AI) basics.pptx
aditichinar
 
ADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITY
ADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITYADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITY
ADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITY
ijscai
 
Structural Response of Reinforced Self-Compacting Concrete Deep Beam Using Fi...
Structural Response of Reinforced Self-Compacting Concrete Deep Beam Using Fi...Structural Response of Reinforced Self-Compacting Concrete Deep Beam Using Fi...
Structural Response of Reinforced Self-Compacting Concrete Deep Beam Using Fi...
Journal of Soft Computing in Civil Engineering
 
Introduction to FLUID MECHANICS & KINEMATICS
Introduction to FLUID MECHANICS &  KINEMATICSIntroduction to FLUID MECHANICS &  KINEMATICS
Introduction to FLUID MECHANICS & KINEMATICS
narayanaswamygdas
 
IntroSlides-April-BuildWithAI-VertexAI.pdf
IntroSlides-April-BuildWithAI-VertexAI.pdfIntroSlides-April-BuildWithAI-VertexAI.pdf
IntroSlides-April-BuildWithAI-VertexAI.pdf
Luiz Carneiro
 
Smart_Storage_Systems_Production_Engineering.pptx
Smart_Storage_Systems_Production_Engineering.pptxSmart_Storage_Systems_Production_Engineering.pptx
Smart_Storage_Systems_Production_Engineering.pptx
rushikeshnavghare94
 
Level 1-Safety.pptx Presentation of Electrical Safety
Level 1-Safety.pptx Presentation of Electrical SafetyLevel 1-Safety.pptx Presentation of Electrical Safety
Level 1-Safety.pptx Presentation of Electrical Safety
JoseAlbertoCariasDel
 
Development of MLR, ANN and ANFIS Models for Estimation of PCUs at Different ...
Development of MLR, ANN and ANFIS Models for Estimation of PCUs at Different ...Development of MLR, ANN and ANFIS Models for Estimation of PCUs at Different ...
Development of MLR, ANN and ANFIS Models for Estimation of PCUs at Different ...
Journal of Soft Computing in Civil Engineering
 
Metal alkyne complexes.pptx in chemistry
Metal alkyne complexes.pptx in chemistryMetal alkyne complexes.pptx in chemistry
Metal alkyne complexes.pptx in chemistry
mee23nu
 
Machine learning project on employee attrition detection using (2).pptx
Machine learning project on employee attrition detection using (2).pptxMachine learning project on employee attrition detection using (2).pptx
Machine learning project on employee attrition detection using (2).pptx
rajeswari89780
 
Data Structures_Introduction to algorithms.pptx
Data Structures_Introduction to algorithms.pptxData Structures_Introduction to algorithms.pptx
Data Structures_Introduction to algorithms.pptx
RushaliDeshmukh2
 
Compiler Design Unit1 PPT Phases of Compiler.pptx
Compiler Design Unit1 PPT Phases of Compiler.pptxCompiler Design Unit1 PPT Phases of Compiler.pptx
Compiler Design Unit1 PPT Phases of Compiler.pptx
RushaliDeshmukh2
 
Data Structures_Searching and Sorting.pptx
Data Structures_Searching and Sorting.pptxData Structures_Searching and Sorting.pptx
Data Structures_Searching and Sorting.pptx
RushaliDeshmukh2
 
five-year-soluhhhhhhhhhhhhhhhhhtions.pdf
five-year-soluhhhhhhhhhhhhhhhhhtions.pdffive-year-soluhhhhhhhhhhhhhhhhhtions.pdf
five-year-soluhhhhhhhhhhhhhhhhhtions.pdf
AdityaSharma944496
 
fluke dealers in bangalore..............
fluke dealers in bangalore..............fluke dealers in bangalore..............
fluke dealers in bangalore..............
Haresh Vaswani
 
introduction to machine learining for beginers
introduction to machine learining for beginersintroduction to machine learining for beginers
introduction to machine learining for beginers
JoydebSheet
 
Mathematical foundation machine learning.pdf
Mathematical foundation machine learning.pdfMathematical foundation machine learning.pdf
Mathematical foundation machine learning.pdf
TalhaShahid49
 
Degree_of_Automation.pdf for Instrumentation and industrial specialist
Degree_of_Automation.pdf for  Instrumentation  and industrial specialistDegree_of_Automation.pdf for  Instrumentation  and industrial specialist
Degree_of_Automation.pdf for Instrumentation and industrial specialist
shreyabhosale19
 
AI-assisted Software Testing (3-hours tutorial)
AI-assisted Software Testing (3-hours tutorial)AI-assisted Software Testing (3-hours tutorial)
AI-assisted Software Testing (3-hours tutorial)
Vəhid Gəruslu
 
π0.5: a Vision-Language-Action Model with Open-World Generalization
π0.5: a Vision-Language-Action Model with Open-World Generalizationπ0.5: a Vision-Language-Action Model with Open-World Generalization
π0.5: a Vision-Language-Action Model with Open-World Generalization
NABLAS株式会社
 
Artificial Intelligence (AI) basics.pptx
Artificial Intelligence (AI) basics.pptxArtificial Intelligence (AI) basics.pptx
Artificial Intelligence (AI) basics.pptx
aditichinar
 
ADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITY
ADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITYADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITY
ADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITY
ijscai
 
Introduction to FLUID MECHANICS & KINEMATICS
Introduction to FLUID MECHANICS &  KINEMATICSIntroduction to FLUID MECHANICS &  KINEMATICS
Introduction to FLUID MECHANICS & KINEMATICS
narayanaswamygdas
 
IntroSlides-April-BuildWithAI-VertexAI.pdf
IntroSlides-April-BuildWithAI-VertexAI.pdfIntroSlides-April-BuildWithAI-VertexAI.pdf
IntroSlides-April-BuildWithAI-VertexAI.pdf
Luiz Carneiro
 
Smart_Storage_Systems_Production_Engineering.pptx
Smart_Storage_Systems_Production_Engineering.pptxSmart_Storage_Systems_Production_Engineering.pptx
Smart_Storage_Systems_Production_Engineering.pptx
rushikeshnavghare94
 
Level 1-Safety.pptx Presentation of Electrical Safety
Level 1-Safety.pptx Presentation of Electrical SafetyLevel 1-Safety.pptx Presentation of Electrical Safety
Level 1-Safety.pptx Presentation of Electrical Safety
JoseAlbertoCariasDel
 
Metal alkyne complexes.pptx in chemistry
Metal alkyne complexes.pptx in chemistryMetal alkyne complexes.pptx in chemistry
Metal alkyne complexes.pptx in chemistry
mee23nu
 
Machine learning project on employee attrition detection using (2).pptx
Machine learning project on employee attrition detection using (2).pptxMachine learning project on employee attrition detection using (2).pptx
Machine learning project on employee attrition detection using (2).pptx
rajeswari89780
 
Data Structures_Introduction to algorithms.pptx
Data Structures_Introduction to algorithms.pptxData Structures_Introduction to algorithms.pptx
Data Structures_Introduction to algorithms.pptx
RushaliDeshmukh2
 
Compiler Design Unit1 PPT Phases of Compiler.pptx
Compiler Design Unit1 PPT Phases of Compiler.pptxCompiler Design Unit1 PPT Phases of Compiler.pptx
Compiler Design Unit1 PPT Phases of Compiler.pptx
RushaliDeshmukh2
 
Data Structures_Searching and Sorting.pptx
Data Structures_Searching and Sorting.pptxData Structures_Searching and Sorting.pptx
Data Structures_Searching and Sorting.pptx
RushaliDeshmukh2
 

Java Programs Lab File

  • 1. Program 1 Program: WAP in java to print “Hello World”. class Hello { public static void main(String args[ ]) { System.out.println("Hello World"); } }
  • 3. Program 2 Program: WAP in java to implement programs to define a class and instantiate its object. import java.io.*; class Student { int sid; String sname,sadr,sfname,smname; BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); public void input()throws IOException { System.out.println("please input sid,name,fname and mname"); sid=Integer.parseInt(br.readLine()); sname=br.readLine(); sfname=br.readLine(); smname=br.readLine(); } public void display() { System.out.println("Student's id="+sid); System.out.println("Student's name="+sname); System.out.println("Student's father name="+sfname); System.out.println("Student's mother name="+smname); } } class object { public static void main(String args[ ])throws IOException { Student s=new Student(); s.input(); s.display(); } }
  • 5. Program 3 Program: WAP in java to implement constructor and method overloading. class demo { int area(int a) { return(a*a); } int area(int a,int b) { return(a*b); } double area(double a) { return(3.14*a*a); } } class room { public static void main(String args[]) { demo d=new demo(); System.out.println("Area of square="+d.area(5)); System.out.println("Area of rectangle="+d.area(6,4)); System.out.println("Area of circle="+d.area(1.25)); } }
  • 7. Program 4 Program: WAP in java to implement Command line argument. class ComLineTest { public static void main(String args[ ]) { int count,i=0; String s; count=args.length; System.out.println("Number of arguments="+count); while(i<count) { s=args[i]; i=i+1; System.out.println(i+":"+"java is"+s+"!"); } } }
  • 9. Program 5 Program: WAP in java to implement String class. class abc { public static void main(String args[]) { int n,i,j; String s=new String("manju"); System.out.println(" Length of String="+s.length()); int l=s.length(); for(i=0;i<l;i++) { for(j=0;j<=i;j++) System.out.print(s.charAt(j)); System.out.print("n"); } } }
  • 11. Program 6 Program: WAP in java to implement 2D-Arrays. import java .io.*; class element { public static void main(String args[ ])throws IOException { int a[ ][ ]=new int[3][3]; int i,j; BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); System.out.println("please input nine elements for matrices"); for(i=0;i<3;i++) for(j=0;j<3;j++) a[i ][ j]=Integer.parseInt(br.readLine()); System.out.println("the matrices"); for(i=0;i<3;i++) { for(j=0;j<3;j++) System.out.println(a[i][j]+"t"); System.out.println("n"); } } }
  • 13. Program 7 Program: WAP in java to implement Multi-level inheritance. import java.util.*; class multilevel { static Scanner sc=new Scanner(System.in); static class A { int a1,a2; void getdata() { System.out.println("Enter the value of a1 is:"); a1=sc.nextInt(); System.out.println("Enter the value of a2 is:"); a2=sc.nextInt(); } void putdata() { System.out.println("n The value of a1 is:"+ a1 +" and a2:"+ a2); } } static class B extends A { int b1; void add() { b1=a1+a2; System.out.println("n The Sum is:"+b1); } } static class C extends B { int c1; void mul() { c1=b1*a1; System.out.println("The product is :"+c1); } } public static void main(String args[]) { C obj=new C(); obj.getdata(); obj.add(); obj.mul(); } }
  • 15. Program 8 Program: WAP in java implement the use of interface. interface my { public void show(); } class demo implements my { public void show() { System.out.println("This is interface program"); } } class sks { public static void main(String args[]) { demo d=new demo(); d.show(); } }
  • 17. Program 9 Program: WAP in java implement method overriding. class One { void display() { System.out.println("I am class One"); } } class Two extends One { void display() { System.out.println("I am class Two"); } } class Overriding { void display() { System.out.println("I am from class override"); } public static void main(String args[]) { Overriding obj=new Overriding(); obj.display(); Two t=new Two(); t.display(); } }
  • 19. Program 10 Program: WAP in java to implement Multithreading. class A extends Thread { public void run() { for(int i=1;i<5;i++) { System.out.println("t from Thread A:"+i); } System.out.println("Exit from Thread A"); } } class B extends Thread { public void run() { for(int j=0;j<5;j++) { System.out.println("t from Thread B:"+j); } System.out.println("Exit from Thread B"); } } class threadtest { public static void main(String args[]) { A ob=new A(); B ob1=new B(); ob.start(); ob1.start(); } }
  • 21. Program 11 Program: WAP in java to implement Exception Handling. class Error { public static void main(String args[]) { int a=10,b=5,c=5,x,y; try { x=a/b-c; } catch(Exception e) {} { System.out.println("Division by zero"); } y=a/b+c; System.out.println("y="+y); } }
  • 23. Program 12 Program: WAP in java to implement User-defined and pre-defined packages. package package1; public class A { public void display() { System.out.println("This is class A"); } } import package1.A; class Packagetest1 { public static void main(String args[]) { A obj=new A(); obj.display(); } }
  • 25. Program 13 Program: WAP in java to implement applet using Graphics class. import java.awt.*; import java.applet.*; import java.net.*; public class star extends Applet { public void paint(Graphics g) { g.setColor(Color.green); int x[ ]={80,100,150,120,150,80,0,30,0,50}; int y[ ]={10,40,40,70,120,90,120,70,40,40}; g.drawPolygon(x,y,10); g.fillPolygon(x,y,10); } } /*<applet code="star.class"width=500 height=500></applet>*/
  • 27. Program 14 Program: WAP in java to implement the use of I/O Streams. import java.io.*; class First { public static InputStreamReader input=new InputStreamReader(System.in); public static BufferedReader keyboardInput=new BufferedReader(input); static PrintWriter screenOutput=new PrintWriter(System.out,true); public static void main(String[] args)throws IOException { String name; screenOutput.print("What is your name?"); screenOutput.flush(); name=keyboardInput.readLine(); screenOutput.print("nHello"+name); screenOutput.println("java is based on independent platform"); } }
  • 29. Program 15 Program: WAP in java to implement swing program. import javax.swing.*; class program extends JFrame { program() { setTitle("first form"); setSize(300,300); setVisible(true); } } class form { public static void main (String args[ ]) { program p=new program(); } }