Mca java lab manual - Heroku
|Chatanya bharathi institute Of technology |
| |
|Object Oriented Programming Through Java Lab Record |
|For |
|I Yr. MCA II Semester |
|Compiled by Mrs. G.KALPANA, Asst.Professor in MCA Department |
| |
|2014-2015 |
|[Pick the date] |
Department of MASTER OF COMPUTER APPLICATIONS
Chaitanya Bharathi Institute of Technology (Autonomous)
Gandipet, Hyderabad-75.
INDEX
|S.NO |PROGRAMME NAME |P.NO. |
| I |Basic Programs |4 |
| |1)Write java program to print Biggest of 3 Numbers using Logical Operators |4 |
| |2) write a java program to print first 10 numbers in fibonacci series |5 |
| |3) Write a java program to print Factorial of a given number |6 |
| |4)Write java program to print the following o/p |7 |
| |5) Write a java program to print sum of Sum of Digits |8 |
| |6) Write a java Program for swapping two numbers |9 |
| |7)Wrte a java program to print primes up to the given prime number |10 |
| |8) Write java program to check given string is a palindrome or not |11 |
| |9) wajp to print sum of n terms in the series 1/1! +1/2!+1/3!..... |12 |
| |10) Write A Java Program to print Quadratic roots using command line arguments |13 |
| |11) Write a java program to print the names in sorted order using arrays |14 |
| |12) Write a java program to print multiplication table using arrays |15 |
|II |Method Overloading |18 |
| |1)Write a java program to demonstrate method overloading |18 |
| |2)Write a java program to find the volume of a Box using method overloading with different number of |19 |
| |perameters. | |
|III |Constructor overloading : |22 |
| |1) Write a java program to illustrate the concept of constructors and its overloading. |22 |
| |2) Write a java program for Rectangle class using constructor overloading with different no. of parameter list |24 |
| |3) Wajp to copy the values of one object into another using constructor. |26 |
|S.NO |PROGRAMME NAME |P.NO |
|IV |Inheritence |28 |
| |1) Wajp for Rectange class using Simple Inheritance |28 |
| |2) Write a Java program to demonstrate multilevel inheritance. |30 |
| |3) Write a Java program to implement the following hierarchy and find area and perimeter Abstract |31 |
|V |Method Overriding |35 |
| |1)Write a java program for Bank class using Method Overriding. |36 |
| |2) Write a java program to demonstrate Method overriding (use super keyword) |38 |
|VI |Dynamic Method Dispatch |39 |
| |1)Write a Java program to demonstrate dynamic dispatch. |40 |
| |2) Wajp for Bank class using Dynamic Method Dispatch |41 |
|VII |Abstract Class: |43 |
| |1) Write a Java program to implement a Vehicle Abstract class. |43 |
| |2)Wajp to demonstrate the concept of abstract class |46 |
|VIII |Packages: |48 |
| |1)Write a Java program to demonstrate use of user defined packages. |49 |
| |2) write a java package for book class and then import and display the result. |50 |
| |3) write a java program to find the cube of a number for various data types using package and then import and |51 |
| |display the results. | |
|IX |Interfaces: |53 |
| |1) Write a Java program to illustrate the multiple inheritance by using Interfaces. |53 |
|X |Super , Static, final key words : |56 |
| |1)Write a java program to illustrate the keywords i)super ii)static iii)final |56 |
|S.NO |PROGRAMME NAME |P.NO |
|XI |Exception handling: |57 |
| |1)wajp to demonstrate simple example for exception handling |57 |
| |2)Wajp to demonstrate exception handling with multiple catch blocks |58 |
| |3) wajp using NumberFormat exception |60 |
| |4)Wajp for user defined exception |61 |
|XII |How to make executable jar files in JDK1.3.1? |63 |
|XIII |Multithreading |64 |
| |1) Write a Java program to demonstrate the concept of daemon threads |64 |
| |2) Write a Java program to demonstrate the concept of synchronization by suitable example |66 |
| |3) Write a Java program to demonstrate the concept of Inter thread communication by Suitable example |68 |
| |4) Write a program to demonstrate string tokenizer. |70 |
|XIV) |File I/O and Streams |73 |
| |1)Wajp to Demonstration of FileOutputStream and PrintStream classes |74 |
| |2) Write a java program to Write bytes to a file |75 |
| |3) Write a java program to copy bytes from one file to another. |76 |
|XV |Applets |79 |
| |1) Wajp for Sum of Two Numbers using Applet |79 |
| |2)Wajp for Applet using drawstring(), drawRect() and drawOval() |80 |
| |3) Write a Java program to demonstrate banner applet. |81 |
| |4) wajp for Bouncing of a Ball using applet |83 |
|XIV |AWT: 1 ) Wajp that prints a message by clicking on the button using AWT 2) Wajp to demonstrate |87 |
| |Grid Layout manager using AWT 3) GUI with controls menus and event | |
| |handling using SWING | |
Java lab programmes
Basic programs:
| |
1) Write java program to print Biggest of 3 Numbers using Logical Operators
Importjava.util.*;
class Biggest3
{
public static void main(String args[])
{
int n1, n2, n3, big;
Scanner scan= new Scanner(System.in);
System.out.print("Please Enter No 1: ");
n1=scan.nextInt();
System.out.print("Please Enter No 2: ");
n2=scan.nextInt();
System.out.print("Please Enter No 3: ");
n3=scan.nextInt();
if(n1>n2 && n1>n3)
big=n1;
else if(n2>n1 && n2>n3)
big=n2;
else
big=n3;
System.out.println("Biggest No: " + big);
}
}
O/P:
[pic]
2) write a java program to print first 10 numbers in fibonacci series
classFibo
{
public static void main(String args[])
{
inta,b,temp,n;
a=0;
b=1;
for(n=1;n=1;i--)
{
fact=fact*i ;
}
System.out.println("Factorial of " + n + " is " + fact);
}
}
O/P:
[pic]
4)Write java program to print the following o/p
Following star pattern is printed
*
**
***
****
*****
class Stars
{
Public static voidmain(String[]args)
{
int row, numberOfStars;
for(row =1; row 0)
{
res=n%10;
n=n/10;
sum=sum+res;
}
System.out.print(+sum);
}
}
o/p:
[pic]
6) Write a java Program for swapping two numbers
importjava.util.*;
class Swap
{
public static void main(String args[])
{
int n1, n2, temp;
Scanner scan= new Scanner(System.in);
System.out.print("Please Enter No 1:=");
n1=scan.nextInt();
System.out.print("Please Enter No 2: =");
n2=scan.nextInt();
temp=n1;
n1=n2;
n2=temp;
System.out.println("First No: " + n1);
System.out.println("Second No: " + n2);
}
}
o/p:
[pic]
7)Wrte a java program to print primes up to the given prime number
importjava.util.*;
public class Prime
{
public static void main(String args[])
{
inti,j,p=1;
Scanner sc =new Scanner(System.in);
System.out.print("enter a number up to which u want print primes =");
int n=sc.nextInt();
for(i=2;i ................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.