import java.util.Scanner; public class Greater { public static void main(String args[]) { Scanner scr = new Scanner(System.in); System.out.println("Enter value:"); int x=scr.nextInt(); System.out.println("Enter value:"); int y=scr.nextInt(); if(x>y) { System.out.println("Message : X is greater"); } } } pro2 public class Factorial { public static void main(String args[]) { int number = 10; int fact = 1; int i=1; while( i<=number ) { fact=fact*i; System.out.println(i+"! ="+fact); i++; } } } pro3 import java.util.Scanner; class Circle { public static void main(String args[]) { Scanner scr = new Scanner(System.in); System.out.println("Enter a radius: "); int radius= scr.nextInt(); float PI = 3.142f; double area = PI * (radius * radius); System.out.println("Area is:"+area); double circumference= 2*PI*radius; System.out.println( "\nCircumference is:”+circumference) ; } } pro4 public class MethodOverload { int add() { return 50+60; } int add(int a,int b) { return a+b; } float add(float x,float y) { return x+y; } public static void main(String args[]) { MethodOverload MO = new MethodOverload(); System.out.println("By using default values, sum is :"+MO.add()); System.out.println("SUM of two integers numbers is :"+MO.add(10,20)); System.out.println("SUM of two float numbers is :"+MO.add(10.5f,20.5f)); } } pro5 class addsub { int num1 = 10; int num2 = 20; int add() { return num1+num2; } int sub() { return num1-num2; } } class multdiv extends addsub { int mul() { return num1*num2; } float div() { return num2/num1; } } public class MathOp { public static void main(String arg[]) { multdiv ml=new multdiv(); System.out.println("Addition =" +ml.add()); System.out.println("Subtraction =" +ml.sub()); System.out.println("Multiply =" +ml.mul()); System.out.println("Division =" +ml.div()); } } pro6 class Student { int rollno; String name; static String college="BCA DEGREE College"; Student(int r, String n) { rollno=r; name=n; } void display() { System.out.println(rollno+" "+name+" "+college); } } class StaticUse { public static void main(String[] args) { System.out.println("Objects sharing the static variable - college"); Student s1=new Student(111,"Avinash"); Student s2=new Student(112,"Sandhya"); s1.display(); s2.display(); System.out.println("Static value changed by one of the object"); s1.college="S.J.P.N BCA College"; s1.display(); s2.display(); } } pro7 import java.util.*; class Student { Scanner sc=new Scanner(System.in); Int Enrollment_id; String name; int sub1,sub2,sub3,total; Student() { readInfo(); } public void readInfo() { System.out.println("Enter Student Details"); System.out.println("Enrollment Id:"); Enrollment_id=sc.nextInt(); System.out.println("Name:"); name=sc.next(); System.out.println("Enter marks in 3 subjects:"); sub1=sc.nextInt(); sub2=sc.nextInt(); sub3=sc.nextInt(); if(sub1>=50 && sub2>=50 && sub3>=50) { total=sub1+sub2+sub3; } else { total=0; } } public void display() { System.out.println(Enrollment_id+"\t\t"+name+"\t"+total); } } public class StudentResult { public static void main(String args[]) { Student s[]=new Student[3]; for(int i=0; i<3; i++) { s[i]=new Student(); } System.out.println("Student Details"); System.out.println("Enrollment_id \t name \t total"); for(int i=0; i<3; i++) { s[i].display(); } } } pro8 interface vehicleone { int speed=90; public void distance(); } interface vehicletwo { int distance=100; public void speed(); } class Vehicle implements vehicleone,vehicletwo { int time=5; public void distance() { int distance=speed*time; System.out.println("distance travelled is "+distance); } public void speed() { int speed=distance/time; System.out.println("speed of distance travelled is "+speed); } } class MultipleInheritance { public static void main(String args[]) { Vehicle obj = new Vehicle(); System.out.println("Vehicle"); obj.distance(); obj.speed(); } } pro9 class ThreadExample extends Thread { public void run() { for(int i= 1; i<=5; i++) { System.out.println("Extending Thread is Running"); } } } class RunnableThread implements Runnable { public void run() { for(int i= 1; i<=5; i++) { System.out.println("Runnable interface Thread is Running"); } } } public class Thread_Test { public static void main(String[] args) { ThreadExample t1 = new ThreadExample(); t1.start(); RunnableThread t2 = new RunnableThread(); Thread thread = new Thread(t2); thread.start(); } }