المشاركات

Write a java program to demonstrate the implementation of abstract class. | VCMIT

صورة
Implementation of Abstract Class. INPUT import java.util.Scanner; abstract class test { abstract void get(); } class test1 extends test { void get() { int a,b; Scanner ob=new Scanner(System.in); System.out.print("Enter 1st Number: "); a=ob.nextInt(); System.out.println("Enter 2st Number: "); b=ob.nextInt(); System.out.println("Addition is: "+(a+b)); } } class prac4C { public static void main(String args[]) { test1 obj=new test1(); obj.get(); } } OUTPUT

Designed a class that demonstrates the use of constructor and destructor. | VCMIT

صورة
Constructor And Destructor. INPUT class Square{ int width,height; Square( int a , int b){ width = a; height = b; } int area(){ return width * height; } } class Cal{ public static void main(String[] args){ { Square s1 = new Square(10,20); int area_of_sqaure = s1.area(); System.out.println("The area of square is:" + area_of_sqaure); } } } OUTPUT

Designed a class SortData that contains the method asec() and desc(). | VCMIT

صورة
The Method asec() And desc(). INPUT import java.util.*; class prac4A { Scanner input=new Scanner(System.in); int num,i; int arr[]; int temp=0; public void getdata() { System.out.print("Enter the size of array: "); num=input.nextInt(); arr=new int[num]; System.out.print("Enter the number: "); for( i=0;i<num;i++) { arr[i]=input.nextInt(); } } void putdata() { System.out.print("Given numbers are: "); for(i=0;i<num;i++) { System.out.println(arr[i]); } } void asce() { for(i=0;i<num;i++) { for(int j=i+1;j<num;j++) { if(arr[i]>arr[j]) { temp=arr[i]; arr[i]=arr[j]; arr[j]=temp; } } } System.out.print("Ascending order of number are: "); for(int i=0;i<num;i++) { System.out.println(arr[i]); } } void desc() { for(i=0;i<num;i++) { for(int j=i+1;j<num;j++) { if(arr[i]<arr[j]) { temp=arr[i]; arr[i]=arr[j]; arr[j]=temp; } } } System.out.print("Descending order o...