22. Write a program in java to input some integer number using keyboard arrange and print all input number in array in ascending order?

import java.io.DataInputStream; class Ascending {                 public static void main(String args[])                 {                                 DataInputStream in=new DataInputStream(System.in);                                 int n[],x=0,i,j,t;                                 n=new int[100];                                 try                                 {                                                 System.out.println("Enter Size of Array : ");                                                 x=Integer.parseInt(in.readLine());                                                 for(i=0;i<x;i++)                                                                 n[i]=Integer.parseInt(in.readLine());                                                 for(i=0;i<x-1;i++)                                                                 for(j=i+1;j<x;j++)                                                                                 if(n[i]>n[j])                                                                                 {                                                                                                 t=n[j];                                                                                                 n[j]=n[i];                                                                                                 n[i]=t;                                                                                ... Continue Reading →

Advertisements

Package: –

Package: - Packages are java’s way of grouping a variety of classes and/or interfaces together. The grouping is usually done according to functionality. In fact, packages act as container for classes. By organizing our classes into packages, we achieve the following benefits – The classes contained in the packages of another program can be easily... Continue Reading →

21. Write a program in java to input some integer number from keyboard. Find and print a largest integer out of all input numbers?

import java.io.DataInputStream; class Test {                 public static void main(String args[])                 {                                 DataInputStream in=new DataInputStream(System.in);                                 int n[],x,i,l=0;                                 try                                 {                                                 System.out.println("Enter Size of Array : ");                                                 x=Integer.parseInt(in.readLine());                                                 n=new int[x];                                                 for(i=0;i<x;i++)                                                                 n[i]=Integer.parseInt(in.readLine());                                                 for(i=0;i<x;i++)                                                                 if(n[i]>l)                                                                                 l=n[i];                                 }                                 catch(Exception e) {}                                 System.out.println("Largest No... Continue Reading →

Interface: –

Interface: - A java is programming language like C++ but it does not support multiple inheritance. The designer of java could not overlook the importance of multiple inheritance. A large number of real life application they require use of multiple inheritance whereby we inherit methods and property from several distinct classes. Since C++ like implementation... Continue Reading →

Create a website or blog at WordPress.com

Up ↑

%d bloggers like this: