• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
projectsgeek

ProjectsGeek

Download Mini projects with Source Code, Java projects with Source Codes

  • Home
  • Java Projects
  • C++ Projects
  • VB Projects
  • PHP projects
  • .Net Projects
  • NodeJs Projects
  • Android Projects
    • Project Ideas
      • Final Year Project Ideas
      • JSP Projects
  • Assignment Codes
    • Fundamentals of Programming Language
    • Software Design Laboratory
    • Data Structure and Files Lab
    • Computer Graphics Lab
    • Object Oriented Programming Lab
    • Assembly Codes
  • School Projects
  • Forum

Java Assignments

Multiple Inheritance in java program

September 3, 2011 by ProjectsGeek Leave a Comment

Multiple Inheritance in java program

import java.util.*;
import java.io.*;
class c1
{
int length=20;
void ln()
{
System.out.print(length);
}
}
interface intf
{
int breadth=40;
void br();
}
public class c3 extends c1 implements intf
{
public static void main(String[] args)
{
c3 c= new c3();
c.ln();
c.br();
}
public void br()
{
System.out.print(breadth);
}
}

Other Projects to Try:

  1. To Implement a Program Retrieval of Documents using Inverted Files
  2. Implement a Program for Feature Extraction in 2D Colour Images (any features like Colour, Texture etc.)
  3. Java Programming from program analysis to program Design By -DS Malik
  4. File Handling program using Java
  5. Web Service for Multiple clients Project Idea

Filed Under: Java Assignments

Developing Clock In java using Multi threading

September 2, 2011 by ProjectsGeek 3 Comments

Developing Clock In java using Multi threading
Developing Clock In java using Multi threading 1

import java.util.*;
import java.awt.*;
import java.applet.*;
import java.text.*;
public class Clock extends Applet implements Runnable
{
Thread timer;       // The thread that displays clock
SimpleDateFormat formatter;  // Formats the date displayed
Date currentDate;            // Used to get date to display
Color handColor,numberColor;   // Color of main hands and dial// Color of second hand and numbers
int xcenter = 80, ycenter = 55; // Center position
public void init()
{
formatter = new SimpleDateFormat (“EEE MMM dd hh:mm:ss yyyy”);
currentDate = new Date();
handColor = Color.blue;
numberColor = Color.darkGray;
}
public void paint(Graphics g)
{
int xh, yh, xm, ym, xs, ys;
int s = 0, m = 10, h = 10;
String today;
currentDate = new Date();
formatter.applyPattern(“s”);
s = Integer.parseInt(formatter.format(currentDate));
formatter.applyPattern(“m”);
m = Integer.parseInt(formatter.format(currentDate));
formatter.applyPattern(“h”);
h = Integer.parseInt(formatter.format(currentDate));
xs = (int) (Math.cos(s * Math.PI / 30 – Math.PI / 2) * 45 + xcenter);
ys = (int) (Math.sin(s * Math.PI / 30 – Math.PI / 2) * 45 + ycenter);
xm = (int) (Math.cos(m * Math.PI / 30 – Math.PI / 2) * 40 + xcenter);
ym = (int) (Math.sin(m * Math.PI / 30 – Math.PI / 2) * 40 + ycenter);
xh = (int) (Math.cos((h*30 + m / 2) * Math.PI / 180 – Math.PI / 2) * 30 + xcenter);
yh = (int) (Math.sin((h*30 + m / 2) * Math.PI / 180 – Math.PI / 2) * 30 + ycenter);
formatter.applyPattern(“EEE MMM dd HH:mm:ss yyyy”);
today = formatter.format(currentDate);
g.setColor(numberColor);
g.drawString(today, 5, 125);
g.drawLine(xcenter, ycenter, xs, ys);
g.setColor(handColor);
g.drawLine(xcenter, ycenter-1, xm, ym);
g.drawLine(xcenter-1, ycenter, xm, ym);
g.drawLine(xcenter, ycenter-1, xh, yh);
g.drawLine(xcenter-1, ycenter, xh, yh);
g.setColor(handColor);
g.drawArc(xcenter-50, ycenter-50, 100, 100, 0, 360);
g.setColor(numberColor);
g.drawString(“9”, xcenter-45, ycenter+3);
g.drawString(“3”, xcenter+40, ycenter+3);
g.drawString(“12”, xcenter-5, ycenter-37);
g.drawString(“6”, xcenter-3, ycenter+45);
}
public void start()
{
timer = new Thread(this);
timer.start();
}
public void stop()
{
timer = null;
}
public void run()
{
Thread me = Thread.currentThread();
while (timer == me)
{
try
{
Thread.currentThread().sleep(100);
} catch (InterruptedException e) {}
repaint();
}
}
}
 
Download Code

Other Projects to Try:

  1. Multiple Inheritance in java program
  2. Threads in Java Tutorial for Beginners
  3. Java Applet Tutorial for Beginners
  4. Moving Balls mini project using Java Applet
  5. Design an applet that displays the string “Hello College Name” moving from left to right. When it reaches to right, it scrolls back to left.

Filed Under: Java Assignments

Database connectivity in Java with MYSQL

September 2, 2011 by ProjectsGeek Leave a Comment

Database connectivity in Java with MYSQL
import java.io.*;
import java.sql.*;
public class jdjd
{
static BufferedReader br;
Connection conn;
Statement stmt;
jdjd () throws Exception
{
String driver=”sun.jdbc.odbc.JdbcOdbcDriver”;
String url=”jdbc:odbc:dbase”;
Class.forName(driver);
conn=DriverManager.getConnection(url);
stmt=conn.createStatement();
}
void addrec() throws Exception
{
String s1,s2,sql;
System.out.println(“Enter Roll No. : “);
s1=br.readLine();
System.out.println(“Enter Name : “);
s2=br.readLine();
sql=”insert into student values(” + s1 + “, ‘” + s2 + “‘)”;
stmt.executeUpdate(sql);
}
void viewrec() throws Exception
{
int i,cols;
String sql=”select * from student”;
ResultSet rs=stmt.executeQuery(sql);
ResultSetMetaData rsmd=rs.getMetaData();
cols=rsmd.getColumnCount();
for(i=1;i<=cols;i++)
{
System.out.println(” ” + rsmd.getColumnClassName(i));
}
while(rs.next())
{
System.out.println();
for(i=1;i<=cols;i++)
{
System.out.println(” ” + rs.getString(i));
}
}
}
void search() throws Exception
{
int i,cols;
String s1;
System.out.println(“Enter Roll No. : “);
s1=br.readLine();
String sql=” select name from student where rno=”+s1+” “;
ResultSet rs=stmt.executeQuery(sql);
ResultSetMetaData rsmd=rs.getMetaData();
cols=rsmd.getColumnCount();
for(i=1;i<=cols;i++)
{
System.out.println(” ” + rsmd.getColumnClassName(i));
}
while(rs.next())
{
System.out.println();
for(i=1;i<=cols;i++)
{
System.out.println(” ” + rs.getString(i));
}
}
}
void update() throws Exception
{
int i,cols;
String s1,s2;
System.out.println(“Enter Roll No. to Update: “);
s1=br.readLine();
System.out.println(“Enter New Name : “);
s2=br.readLine();
String sql=” update student set name = ‘” + s2 + “‘ where rno=” + s1 + ” “;
stmt.executeUpdate(sql);
}
void delrec() throws Exception
{
String s1,s2,sql;
System.out.println(“Enter Roll No. : “);
s1=br.readLine();
sql=”delete from student where rno=”+s1;
stmt.executeUpdate(sql);
}
void closeAll() throws Exception
{
stmt.close();
conn.close();
}

public static void main (String args[])
{
try
{
br=new BufferedReader(new InputStreamReader(System.in));
String temp;
jdjd d=new jdjd();
do
{
System.out.println(“1.Add Record”);
System.out.println(“2.View Record”);
System.out.println(“3.Delete Record”);
System.out.println(“4.Search Record”);
System.out.println(“5.Update Record”);
System.out.println(“5.Exit”);
System.out.println(“Enter UR Choice”);
temp=br.readLine();
if(temp.equals(“1”))
{
d.addrec();
}
else if(temp.equals(“2”))
{
d.viewrec();
}
else if(temp.equals(“3”))
{
d.delrec();
}
else if(temp.equals(“4”))
{
d.search();
}
else if(temp.equals(“5”))
{
d.update();
}

}while(!temp.equals(“6”));
d.closeAll();

}
catch(Exception e)
{
System.out.println(e);
}
}
}

Download Code

Other Projects to Try:

  1. Exception Handling In java
  2. File Handling program using Java
  3. To Perform various String Operation in Java
  4. SQL and JDBC(Java Database Connectivity) in Java
  5. Write a program in Java for student details (Roll No, Name etc) to Access as a database and write the application in JDBC. (AWT or JFame).

Filed Under: Java Assignments

File Handling program using Java

September 2, 2011 by ProjectsGeek Leave a Comment

File Handling program using Java
import java.io.*;
import java.util.*;
class record implements Serializable
{
static Scanner input=new Scanner(System.in);
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int roll;
String name;

void insert()
{
try
{
System.out.println(“\n Enter Roll No:: “);
roll=input.nextInt();
System.out.println(“\n Enetr Name:: “);
name=br.readLine();
FileOutputStream fout=new FileOutputStream(“Student.txt”,true);
byte buff[]=name.getBytes();
fout.write((char)roll);
fout.write(‘\n’);
fout.write(buff);
fout.write(‘\n’);
fout.close();
}
catch(Exception e)
{
System.out.println(e.getMessage());
}
}
void delete(int r)
{
try
{
FileInputStream fin = new FileInputStream(“student.txt”);
FileOutputStream fout=new FileOutputStream(“temp.txt”);

while(true)
{
int a=fin.read();
if(a==-1)
break;
if(a!=r)
{
fout.write((byte)a);
a=fin.read();
fout.write(a);
while(true)
{
a=fin.read();
if(a==’\n’)
break;
fout.write(a);
}
fout.write(a);
}
else
{
a=fin.read();
do{
a=fin.read();
}while(a!=’\n’);
}
}
fin.close();
fout.close();
File f=new File(“student.txt”);
File f1=new File(“temp.txt”);
if(f.delete())
f1.renameTo(new File(“student.txt”));
else
System.out.println(“Error”);

}
catch(Exception e)
{
System.out.println(e.getMessage());
}
}
void showdata(int r)
{
try
{
FileInputStream fin=new FileInputStream(“student.txt”);
while(true)
{

int a=fin.read();
if(a==-1)
break;
if(a==r)
{
System.out.println(“roll no:: “+a);
a=fin.read();
System.out.println(“Name:: “);
do
{
a=fin.read();
System.out.print((char)a);
}while(a!=’\n’);
}
else
{
do
{
a=fin.read();
}while(a!=’\n’);
}

}

}
catch(Exception e)
{
System.out.println(e.getMessage());
}
}

void show()
{
try
{

FileInputStream fin=new FileInputStream(“student.txt”);
while(true)
{
int a=fin.read();
if(a==-1)
break;
System.out.println(“roll no:: “+a);
a=fin.read();
System.out.println(“Name:: “);
do
{
a=fin.read();
System.out.print((char)a);
}while(a!=’\n’);

}

}
catch(Exception e)
{
System.out.println(e.getMessage());
}
}
}

public class Student extends record
{
public static void main(String args[])
{
try
{
while(true){
System.out.println(“\nEnter your choice : “);
System.out.println(“1:Insert.”);
System.out.println(“2:Delete.”);
System.out.println(“3:View record.”);
System.out.println(“4:View All.\n”);
int choice=input.nextInt();
record r=new record();
switch(choice)
{
case 1:
r.insert();
break;
case 2:
System.out.println(“Enter roll no. : “);
int roll=input.nextInt();
r.delete(roll);
break;
case 3:
System.out.println(“Enter roll no. : “);
roll=input.nextInt();
r.showdata(roll);
break;
case 4:
r.show();
break;
default:
System.out.println(“Invalid Entry !!”);
break;
}
}
}
catch(Exception e)
{
System.out.println(e.getMessage());
}
}
}

Download Code

Other Projects to Try:

  1. Database connectivity in Java with MYSQL
  2. File Handling and IO Handling in Java Programming
  3. To Perform File Handling in Java
  4. Implement Conflation Algorithm using File Handling in Java
  5. Exception Handling In java

Filed Under: Java Assignments

Exception Handling In java

September 2, 2011 by ProjectsGeek Leave a Comment

Exception Handling In java
import java.io.*;
import java.util.*;
class myex extends Exception
{
myex(String m)
{
super(m);
}
}
class myex1 extends Exception
{
myex1(String m)
{
super(m);
}
}
public class Bank
{
static Scanner input=new Scanner(System.in);
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int bal;
static int accno;
String name;
Bank()
{
bal=0;
accno=2873;
name=””;
}
void newacc()
{
try
{

System.out.println(“\n Enter Name:: “);
name=br.readLine();
accno++;
System.out.println(“\n Your Acc No:: “+accno);
}
catch(Exception e){}
}
void showinfo() throws myex
{

System.out.println(“\n Enter Acc No:: “);
accno=input.nextInt();
if(accno<0)
{
throw new myex(“\naccount no is wrong\n”);
}
System.out.println(“\n Your name is:: ” + name);
}
void wd() throws myex1,myex
{

System.out.println(“\n Enter Acc No:: “);
accno=input.nextInt();
if(accno<0)
{
throw new myex(“\naccount no is wrong\n”);
}
System.out.println(“\n Enter Money:: “);
int money=input.nextInt();
if(money%100!=0)
{
throw new myex1(“\nmoney sd be multiple of 100 \n”);
}
System.out.println(“\n Your name is:: ” + name);
}
public static void main (String[] args)

{
int ch;
Bank b =new  Bank();
do
{

System.out.println(“\n 1.New Acc”);
System.out.println(“\n 2.Acc Info”);
System.out.println(“\n 3.Dep”);
System.out.println(“\n 4.Wd”);
System.out.println(“\n Enter Ur Choice”);
ch=input.nextInt();

switch(ch)
{
case 1:
b.newacc();
break;
case 2:
try
{

b.showinfo();

}catch(Exception e)

{
System.out.println(e.getMessage());
}
break;
case 3:
try
{
b.wd();
}
catch(Exception e)
{
System.out.println(e.getMessage());
}
break;

}

}while(ch!=5);
}
}

Other Projects to Try:

  1. Database connectivity in Java with MYSQL
  2. Exception Handling in C++ Language
  3. File Handling and IO Handling in Java Programming
  4. To Perform File Handling in Java
  5. File Handling program using Java

Filed Under: Java Assignments

  • « Go to Previous Page
  • Page 1
  • Page 2

Primary Sidebar

Tags

.Net Projects Download Android Project Ideas Android Projects Angular 2 Assembly Codes C # Projects C & C++ Projects C++ Projects Class Diagrams Computer Graphics Database Project Data Mining Projects DataScience Projects Datastructure Assignments Download Visual Basic Projects Electronics project Hadoop Projects Installation Guides Internet of Things Project IOS Projects Java Java Interview Questions Java Projects JavaScript JavaScript Projects java tutorial JSON JSP Projects Mechanical Projects Mongodb Networking Projects Node JS Projects OS Problems php Projects Placement Papers Project Ideas Python Projects seminar and presentation Struts

Search this Website


Footer

Download Java Project
Download Visual Basic Projects
Download .Net Projects
Download VB Projects
Download C++ Projects
Download NodeJs Projects
Download School Projects
Download School Projects
Ask Questions - Forum
Latest Projects Ideas
Assembly Codes
Datastructure Assignments
Computer Graphics Lab
Operating system Lab
australia-and-India-flag
  • Home
  • About me
  • Contact Form
  • Submit Your Work
  • Site Map
  • Privacy Policy