Showing posts from May, 2021Show all

8) Write a Java program to illustrate String handling functions like concat, length, toLowerCase, toUpperCase, equals.

Write a Javaprogram to illustrate Java string handling for following functions: Concatenation of “dbjcollege”,”chiplun”, Reverse of “12721”. Determine whether the two strings:”dbjcollege”,”DBJCollege” are equal or not? Convert  the string “Hello World” to uppercase. Convert the string “Let Us C”to lowercase.Length of…

Read more

2) Write a Java program that download file from the Internet and either copy it as a file on local machine , or output it to the screen.

source file name:  DownloadFileDemo.java import java.io.*;   import java.net.*;    class DownloadFileDemo {   public static void main(String[] dbj) {   InputStream in=null; OutputStream out=null; try {   URL url=new URL(dbj[0]); in=url.openStream(); if(dbj.length==2) out=new FileOutputStream(dbj[1]); else out=System.o…

Read more

6) Write a Java program on Single Inheritance.

Single Inheritance  source file name: singledemo.java class A { void sum(int a, int b) { System.out.println("addition ="+(a+b)); } } class B extends A { void sub(int a, int b) { System.out.println("subtraction ="+(a-b)); } } class singledemo { public static void main(String as[]) { System.out.prin…

Read more

5) Write a Java program on Hierarchical Inheritance.

Hierarchical Inheritance : source file name:  Hierarchicaldemo.java class A  {  void sqcube(int n)  {  int sq=n*n;  int c=n*n*n;  System.out.println("square="+sq+" cube="+c);  }  }  class B extends A  {  void add(int a,int b)  {  System.out.println("sum="+(a+b));  } void sub(int a,int b)…

Read more

4) Write a Java program on Multilevel Inheritance.

Multilevel Inheritance: Source file Name: Multileveldemo.java class A  {  void sum(int a,int b)  {  System.out.println("sum="+(a+b)); }  }  class B extends A  {  void sub(int a,int b)  {  System.out.println("substract="+(a-b)); } }  class C extends B  {  void sqcube(int n)  {  int sq=n*n;  int c=…

Read more

6) Write a Java Program that reads a file, converts each tab character to a space character, and writes its output to another file , both files passed through CMD line.

source file name:    TabsDemo.java import java.io.*; public class TabsDemo { public static void main(String[]args) { File infile=new File(args[0]); File outfile=new File(args[1]); FileReader ins=null; FileWriter fos=null; int cnt=0; try{ ins=new FileReader(infile); fos=new FileWriter(outfile); int ch;  while((ch=ins.r…

Read more

5) Write Java Program writes the first 15 numbers of the Fibonacci series to a file and reads this data from a file and display it , files names passed through CMD line.

Write an application that writes the first 15 numbers of the Fibonacci series to a file .Write a second application that reads this data from a file and display it. For both application, specify, the name of the file  as command-line argument. source file name:  fibfilewrite.java   import java.io.*; class fibfilewrit…

Read more

9) Write a Java program that finds largest integer and smallest integer from 10 given array numbers , program also display 5 elements per line.

Initialize an array of size 10 and find the largest integer and smallest integer in the array. Also to display the array elements 5 per line then display in the new line the largest and smallest integer. class array8 { public static void main(String as[]) { int arr[]={10,5,25,3,-4,100,1000,-10,77,38}; System.out.pri…

Read more

9) Write a Java program to determine whether they form a triangle and whether triangle is equilateral, isosceles or scalene using 3 numbers.

Write a Java program to by considering three positive integer a,b and c and determine whether they can form three sides of a triangle .if yes determine whether triangle is equilateral, isosceles or scalene. Display the message accordingly. import java.lang.Math; class Triangle { public static void main(String args[]…

Read more

8) Write a java program to determine whether they form a triangle and whether triangle is right angle or obtuse or acute using 3 numbers.

Write a java program to by considering three positive integers a,b and c determine whether they can form three sides of a triangle yes determine whether triangle is right angle or obtuse or acute. Display the message accordingly. import java.lang.Math; class RightTriangle { public static void main(String args[]) { i…

Read more