JAVA LAB MANUAL
Program 1:
package java_lab_manual;
public class HelloWorld {
public static void main(String[] args) {
[Link]("HELLO WORLD");
Program 2:
package java_sample_programs;
import [Link].*;
public class ReadNumber {
public static void main(String[] args) {
Scanner in = new Scanner([Link]);
[Link]("Enter a number\n");
int a= [Link]();
[Link]("Enter a number\n");
int b= [Link]();
[Link](a);
[Link](b);
int c = a+b;
[Link]("the sum is %d",c);
}
Program 3:
package java_lab_manual;
import [Link].*;
public class CalenderMonth {
public static void main(String[] args) {
String[] month={"jan","feb","mar","apr","may","jun","jul",
"aug","sep","oct","nov","dec" };
for(int i=0;i<12;i++){
[Link](month[i]);
}
Program 3:
package java_lab_manual;
import [Link].*;
public class DivisionByZero {
public static void main(String[] args) {
Scanner sc = new Scanner([Link]);
[Link]("Enter numerator");
int num=[Link]();
[Link]("Enter denominator");
int deno=[Link]();
try {
int result=num/deno;
[Link](result);
}
catch (ArithmeticException e){
[Link]("Arithmatic exception division by zero not
allowed");
}
}
Program 4:
package java_lab_manual;
import [Link].*;
class PayOutOfBounds extends Exception{
public void showError() {
[Link]("Invalid Pay");
}
}
public class ErrorTest {
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner([Link]);
try {
[Link]("Enter The Pay\n");
float pay=[Link]();
if(pay>10000)
throw new PayOutOfBounds();
[Link](pay);
}
catch(PayOutOfBounds e) {
[Link]();
}
}