Remember
me?
RegisterForgot Your Password?

Java Codes

A complete portal of Java Codes for budding Engineers More »

 

JAVA

BCA SLIPS SOLUTIONS FOR JAVA (TY SEM-1) 

1) Write a java program for a cricket player The program should accept the details from
user (max 10): Player code, name, runs, innings- played and number of times not out. The program should contain following menu:
-Enter details of players.
-Display average runs of a single player.
-Display average runs of all players. (Use array of objects & function overloading)

2) Create a class telephone containing name, telephone number & city and write necessary member functions for the following:
- Search the telephone number with given name.
- Search the name with given telephone number.
- Search all customers in a given city. (Use function overloading)

3) Write a java program which creates class Student (Rollno, Name,- Number of subjects, Marks of each subject)(Number of subjects varies for each student)
- Write a parameterized constructor which initializes roll no, name & Number of subjects and create the array of marks dynamically. Display the details of all students with percentage and class obtained.

4) In a bank, different customers having saving account. Some customers may have taken a loan from the bank. So bank always maintains information about bank depositors and borrowers. Design a Base class Customer (name, phone-number).Derive a class Depositor (accno , balance) from Customer. Again derive a class Borrower (loan-no, loan-amt) from Depositor. Write necessary member functions to read and display the details of ‘n’ customers.

5) Write a program in java to check whether the entered character is alphabet, digit or space character. If it is alphabet then print whether it is capital or small alphabet. Also change the alphabet into the reverse case.

6) Using Class implement Hash table to
1) Accept ‘n’ records of students (Name, Percentage)
2) Display details of all students
Find out highest marks

7) Write a Java Program to accept the details of Employee from the user and display it on
the next Frame. (Use AWT)

8) Write a JAVA program to design a screen using Awt 

9) Define an Employee class with suitable attributes having getSalary() method, which returns salary withdrawn by a particular employee. Write a class Manager which extends a class Employee, override the getSalary() method, which will return salary of manager by adding traveling allowance, house rent allowance etc.

10) Write a Java program to create 2 files F1 and F2.Copy the contents of file F1 by changing the case into file F2.
F2 = F1
Also copy the contents of F1 and F2 in F3.
F3 = F1+F2
Display the contents of F3.
(Use Command Line Arguments. )

11) Create an abstract class Person. Derive two classes Employee and Worker from it. Use proper method to accept and display the details for the same.
The fields of Employee are Emp_no,Emp_name and address. Similar fields for worker are name and working hours

12) Write a java program to accept the details of employee from the user and display Payment slip on the next Frame.

13) Write a java Program to accept ‘n’ no’s through the command line and store all the prime no’s and perfect no’s into the different arrays and display both the arrays.

14) Write a program in Java to accept name of cities from the user and sort them in ascending order (Use Command Line Arguments)

15) Write a Java program to simulate the arithmetic calculator (+ ,- ,* , /).Also add 2 buttons namely ‘on’ to start the calculator and ‘clear’ to clear the text box.
Display appropriate error message in the text box

16) Write a Java program which will create a frame if we try to close it, it should it’s color and it remains visible on the screen(Use swing).

17) Create a class Shape which consists one final method area () and volume ().Create three subclasses Rect, Circle and Triangle and calculate area and volume of it

18) Create an application in Java using Awt to display 4 X 4 squares on the screen. One of the block will be active with black color. All other blocks should be filled with blue color. Provide command buttons as follows to move the active cell. The active cell should be changed only if it is within the boundary of the squares otherwise give the beep.

19) Create an abstract class Shape. Derive three classes sphere, cone and cylinder from it. Calculate area and volume of all. (Use Method overriding)

20) Write a Java program to design a screen using Awt that will take a user name and password. If the user name and password are not same, raise an exception with appropriate message. User can have 3 login chances only. Use clear button to clear the text boxes.

21) Design a screen in Java to handle the mouse events and display the positions of the mouse click in a text box.

22) Write a java program that displays the number of characters, lines & words from a file.

23) Write a java program that reads line of integers. Display each integer and also display sum of all integers

24) Write a java program to accept a number from the user, if number is zero then throw user defined exception “Number is 0” otherwise check whether no is prime or not (Use static keyword).

25) Write a package for Games, which have two classes Indoor and Outdoor. Use a function display () to generate the list of players for the specific games. Use default and parameterized constructors. Make use of protected access specifier. Also use finalize () method.

26) Create a package TYBSc which will have 2 classes as class Mathematics with a methods to add two numbers, add three float numbers and class Maximum with a method to find maximum of three numbers. (Make use of finalize)

27) Following code will be uploaded soon (Contact us for the same)

Write a program in Java to Read ,Update and Delete any record from database. The database will be created in appropriate backend.
Database about Element ( Oxygen, Hydrogen) has following fields ( Atomic weight , Name, Chemical symbol)
The input should be provided through Command Line Argument along with the appropriate data.
Ex. Java Pgm_name R
Will read and show the contents of the table.
Ex. Java Pgm_name U 10 ’Oxygen’ 137
Will update the record according to the name specified. (JDBC)
(Use of file handling concept)

28) Write a class Student with attributes roll no, name, age and course. Initialize values through parameterized constructor. If age of student is not in between 15 and 21 then generate user-defined exception “Age Not Within The Range”.If name contains numbers or special symbols raise exception “Name not valid”.

29) Write a Java program to accept list of files as command line arguments. Display the name and size of all the files. Delete all files with extension as ‘.html’ from the current directory. Appropriate error messages should be printed.(Use vector Array)

30) Write a Java program to design a screen using Awt that will create four text fields. First for the text, second for what to find and third for replace. Display result in the fourth text field. Also display the count of total no. of replacements made. The button clear to clear the text boxes.

Java code to find and replace text

Write a Java program to design a screen using Awt that will create four text fields. First for the text, second for what to find and third for replace. Display result in the fourth text field. Also display the count of total no. of replacements made. The button clear to clear the text boxes.

Code :

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class Ass30 extends JFrame implements ActionListener
{
JLabel textLabel, findLabel, replaceLabel, occurrenceLabel;

Write a Java program to accept list of files as command line arguments. Display the name and size of all the files. Delete all files with extension as ‘.html’ from the current directory. Appropriate error messages should be printed.(Use vector Array)

Java Program for file deletion ,file size display .

Code :

import java.io.*;
import java.util.*;

Java code for User defined exceptions

Write a class Student with attributes roll no, name, age and course. Initialize values  through  parameterized constructor. If age of student is not in between 15 and 21 then generate user-defined exception “Age Not Within The Range”.If name contains numbers or special symbols raise exception “Name not valid”.

Code :

import java.io.*;
class AgeOutOfRangeException extends Exception{}
class NameNotValidException extends Exception{}

class Student

Java program to find maximum and minimum of numbers

Create a package TYBSc which will have 2 classes as class Mathematics with a methods to add two numbers, add three float numbers and class Maximum with a method to find maximum of three numbers. (Make use of finalize)

Description :

Create a folder named TYBsc to save classes named Mathematics.java and Maximum.java

Code :

import TYBSc.*;

Java code for demo of parameterized constructors,protected specifier,finalize method

Write a package for Games, which have two classes Indoor and Outdoor. Use a function display () to generate the list of players for the specific games. Use default and parameterized constructors. Make use of protected access specifier. Also use finalize () method.

Description :

The following code imports a package folder named Games .It contains java files named indoor and outdoor .

Code :

import Games.*;

class Ass25
{
public static void main(String args[])
{

Write a java program to accept a number from the user, if number is zero then throw user defined exception “Number is 0” otherwise check whether number is prime or not (Use static keyword).

Java program for demonstration of User defined exceptions 

Code :

import java.io.*;
class ZeroExc extends Exception { }
class Ass24
{
static int n;

Write a java program that reads line of integers. Display each integer and also display sum of all integers

Java program to calculate sum of  integers

Code :

import java. io.*;
class Ass23
{
public static void main(String args[]) throws Exception
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int n,k,s=0;
System.out.println(“Enter The Integer Number”);
n=Integer.parseInt(br.readLine());
while(n>0)
{
k=n % 10;
System.out.print(” “+k+” “);
n=n/10;
s=s+k;
}
System.out.println();
System.out.println(“Sum Of Digits Of Number is \t” + s);
}
}