Remember
me?
RegisterForgot Your Password?

Java Codes

A complete portal of Java Codes for budding Engineers More »

 

Calculate area and volume using Java

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

Code :

abstract class Shape
{
final void area()
{
System.out.println(“Final Method Can not be Overriden”);
}

Code to demonstrate swings

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

Code :

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

Program for calculator (Java)

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

Code :

import java.awt.*;
import java.awt.event.*;

Code for accepting strings through command line and performing operations on them (Java)

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

Code :

class Ass14
{
public static void main(String args[])
{
int n=args.length;
int i,j;

Code for accepting numbers through command line and performing operations on them (Java)

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.

CODE :

import java.io.*;

Code for employee details using abstract class

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

CODE :

import java.io.*;

File handing in java

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. )

CODE :

import java.io.*;

Code for Interitance (Java)

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.

CODE :

class Emp
{
int eno;
float bsal,gs,tax,pf,ns,ded,da;
String ename;