Core Java Important Notes for interview preparationFull description
Full description
100 Java Programs by TechnoLamror
ISC JAVA
Full description
important Judgements in india
A complete collection of java programs required for ISC class 12 project. Completely error free and with comments and working explanations. Ready to print and submit. contain output along with the ...
must read for civil services
Full description
mike boyle
Np
Descripción completa
Physics (AS-LEVEL)Full description
IAS
Important Tables in SAP FICOFull description
Java 8 in ActionFull description
Thực hành javaDescrição completa
A320 study materialFull description
Radio frequency related 2g
This is third edition of "java in Hindi"series. With this eBook your can learn java in Hindi.
bcc falna updated books free download
Java Programs
1. Write a java program that accepts a string from command line and display on separate line in reverse order.
each character
class Revstring { public static void main(String main(String args[]) { int i=0; String name=args[0]; int a=name.length(); System.out.println(“String System.out.println(“Stri ng length is “+a); char ch[]=new char[name.length()]; for(char ch1:name.toCharArray()) { ch[i]=ch1; i++; } for(int j=name.length()-1;j>=0;j–) j=name.length()-1;j>=0;j–) { System.out.println(ch[j]); } } } Output: C:\javap>java Revstring kuldeep String length is 7 p e e d l u k 2. Write a java program that accepts 5 numbers from command line. If of the number is odd then throw custom exception odd Exception and count such invalid number.
import java.lang.Exception; class OddException extends Exception { OddException(String OddException(String message,int a) { System.out.println(message); System.out.println(“invalid System.out.println(“invalid number is” + a); } } class Oddnumber { public static void main(String main(String args[]) { Muthayammal Engineering Muthayammal Engineering College
Java Programs
Integer n[]=new Integer[5]; int j=0; for(int i=0;i<5;i++) { try { n[i]=Integer.valueOf(args[i]); if(n[i]%2!=0) { j++; throw new OddException(“Number is odd”,n[i]); } } catch(OddException e) { System.out.println(“Caught System.out.println(“Caught my exception”); } } System.out.println(“Invalid System.out.println(“Invalid numbers are: ” + j); } } Output: C:\javap>java Oddnumber 1 2 3 4 5 Number is odd invalid number is1 Caught my exception Number is odd invalid number is3 Caught my exception Number is odd invalid number is5 Caught my exception Invalid numbers are: 3 3. Write a java program that generates 10 random double numbers and store them in a file read the file and display the numbers, sum, avg, max and min.
import java.io.*; import java.*; class f1 { public static void void main(String args[]) throws throws Exception { double j,sum=0,avg,min=0,max=0; double a[]=new double[10]; FileWriter fw=new FileWriter(args[0]); FileReader fr=new FileReader(args[0]); for(int i=0;i<10;i++) { Muthayammal Engineering Muthayammal Engineering College