Practical - 1 A) Write java program to demonstrate Boolean value. public class BooleanDemo { public static void main(String[] args) { int number1 = 5; int number2 = 10; boolean isLessThan = (number1 < number2); System.out.println("The value of number1 is: " + number1); System.out.println("The value of number2 is: " + number2); System.out.println("Is number1 less than number2? " + isLessThan); } } Practical – 2 A) Write java program to find the biggest number among three numbers using if else. public class Biggest{ public static void main (String args[]){ int a=25; int b=35; int c=15; if(a>=b && a>=c){ System.out.println(a + " is the biggest number."); }else if(b>=a && b>=c){ System.out.println(b + " is the biggest number."); }else{ System.out.println(c + " is the biggest number."); } } } C) Write a java program to check grade of marks using a switch case. public class Gradecheck{ public static void main (String args[]){ int marks=85; switch(marks/10){ case 10: System.out.println("Grade: O"); System.outprintln(“Remarks : Outstanding”); break; case 9: System.out.println("Grade: A"); System.out.println("Remarks : Excellent"); break; case 8: System.out.println("Grade: B"); System.out.println("Remarks : Very Good"); break; case 7: System.out.println("Grade: C"); System.out.println("Remarks : Good"); break; case 6: System.out.println("Grade: D"); System.out.println("Remarks : Satisfactory"); break; case 5: System.out.println("Grade: E"); System.out.println("Remarks : Needs Improvement"); break; default: System.out.println("Grade: F"); System.out.println("Remarks : Fail - Better luck next time"); } } } Practical – 3 B) Write java program to create a class and access all data members and methods using the object and compute area and perimeter of a circle. public class Circle { double radius; void setRadius(double r){ radius = r; } double area (){ return 3.14* radius * raidus;} double permeter (){ return 2* 3.14159 *radius;} public static void main (String args[]){ Circle obj = new Circle(); obj.setRadius(5.5); System.out.println("Radius : "+ obj.radius()); System.out.println("Are of Circle : "+ obj.area()); System.out.println("Perimeter of Circle : "+ obj.perimeter()); } } Practical- 4 B) Java program to demonstrate multilevel inheritance class Shape { void displayShape() { System.out.println("This is a shape."); } } class Rectangle extends Shape { void displayRectangle() { System.out.println("This is a rectangle."); } } class Area extends Rectangle { int calculateArea(int length, int breadth) { return length * breadth; } } public class MultiInher{ public static void main(String[] args) { Area rect = new Area(); rect.displayShape(); rect.displayRectangle(); int result = rect.calculateArea(8, 4); System.out.println("Area of Rectangle: " + result); } } Practical -5 A) Java program demonstrsting hierarchical inheritance. class Vehicle { void start() { System.out.println("Vehicle is starting..."); } } class Car extends Vehicle { void showCar() { System.out.println("This is a Car."); } } class Bike extends Vehicle { void showBike() { System.out.println("This is a Bike."); } } public class Main { public static void main(String[] args) { Car c = new Car(); Bike b = new Bike(); c.start(); c.showCar(); b.start(); b.showBike(); } } Practical - 6 B) Java Program to find average of three numbers using the method overloading. class AverageCalc{ void average(int a, int b, int c) { double avg = (a + b + c) / 3.0; System.out.println("Average of three integers: " + avg); } void average(double a, double b, double c) { double avg = (a + b + c) / 3.0; System.out.println("Average of three doubles: " + avg); } } public class AverageOverload { public static void main(String[] args) { AverageCalculator obj = new AverageCalculator(); obj.average(10, 20, 30); obj.average(5.5, 10.5, 15.5); } } Practical -7 A). Write java program create an interface area, find the area of a circle. import java.util.*; interface Area { double calculateArea(); } class Circle implements Area { double radius; Circle(double r) { radius = r; } public double calculateArea() { return 3.14 * radius * radius; } } public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.print("Enter radius of the circle: "); double r = sc.nextDouble(); Circle c = new Circle(r); double area = c.calculateArea(); System.out.println("Area of Circle = " + area); } } Practical 8 B) Write a program to demonstrate exception handling in case of variable or constant divided by zero . class Error { public static void main(String args[]) { try { int denominator = 0; if (denominator != 0) { int a = 50 / denominator; System.out.println("Result: " + a); } else { System.out.println("Cannot divide by zero!"); } } catch (ArithmeticException e) { System.out.println("Error: " + e.getMessage()); } } } Practical 10 B) Java program to find factorial of number using user defined packages. Step 1:- package mypackage; public class Factorial { public int findFactorial(int n) { int fact = 1; for (int j = 1; j <= n; j++) { fact *= j; } return fact; } } Step 2:- import mypackage.Factorial; import java.util.Scanner; class MainFactorial { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.print("Enter a number: "); int num = sc.nextInt(); Factorial f = new Factorial(); int result = f.findFactorial(num); System.out.println("Factorial of " + num + " is: " + result); sc.close(); } }