Facebook

adsense

Tuesday, 26 May 2015

Airline Reservation System in java GUI

Airline reservation System will reserve the seats for passenger for the specific flight.It will tell the timing, route ,number of seat for the flight.
This is an outstanding project for the IT student's for the Semester final project.This program will save all the data records of the passenger and their luggage and many more username and password is given below.
You can download this project and explore more functionality present in it.

Sample output:
                       





Click Here to download the source code
 After this please wait for 5 sec and than click on skip ad button to download the code



Note :
  1. After Click on "Click Here" please wait for 5 sec and than click on skip ad button to download the code
  2. Username :- admin                Password :- admin
  3. The main class is loginPage ,so start from there.
  4. If you like the program Please do comment below so i will post more program like that
  5. Do Share the post with Google+ ,facebook,twitter,whatsapps or any other material you have

Friday, 22 May 2015

Snake game in java

Real Snake game in java with great graphics including GUI 
The game will turn over whenever it touches the boundary or touch itself .Game will show the length,Score and Time of game.
You will definately going to "Like" this game .




Click Here to download source code of project


Note :
  1. After Click on "Click Here" please wait for 5 sec and than click on skip ad button to download the code
  2. If you like the program Please do comment below so i will post more program like that
  3. Do Share the post with Google+ ,facebook,twitter,whatsapps or any other material you have 

Tuesday, 19 May 2015

Prison Management System in java

An application is to be developed that manages the wardens and prisoners at a prison. Each prisoner is identified by a unique number. Details, such as name and number of days left to serve in prison, need to be stored for each prisoner as well as the unique identifier. Some prisoners are categorized as high security prisoners, in which case additional information must be stored, such as security level and whether or not the prisoner can share a cell with another prisoner. Wardens have a rank in the range 1 to 5, where a rank of 5 indicates the highest level of experience.
The application must provide at least the following functionalities:
- Add a new prisoner
- Find and display a prisoner, identified by number
- Release a prisoner, identified by number (a prisoner can only be released, at the discretion of the prison services, if they have less than 7 days left to serve)
- Delete a prisoner (this function will come into play in the event of death of a prisoner)
- Add a new prison warden
- Delete a prison warden
- Display all the wardens
- Display all the prisoners


Sample Output :
    




Note :
  1. After Click on "Click Here" please wait for 5 sec and than click on skip ad button to download the code
  2. If you like the program Please do comment below so i will post more program like that
  3. Do Share the post with Google+ ,facebook,twitter,whatsapps or any other material you have .


Monday, 18 May 2015

QUESTION 20

Write code to find the First non repeated character in the String ?
Solution :
Another good Java interview question, This question is mainly asked by Amazon and equivalent companies. See first non repeated character in the string : Amazon interview question

<PREVIOUS || Main Page || NEXT >
         GIVE YOUR COMMENT BELOW

QUESTION 19

What is difference between StringBuffer and StringBuilder in Java ?
Solution :
Classic Java questions which some people thing tricky and some consider very easy. StringBuilder in Java is introduced in Java 5 and only difference between both of them is that Stringbuffer methods are synchronized while StringBuilder is non synchronized. See StringBuilder vs StringBuffer for more differences

             <PREVIOUS || Main Page || NEXT >
               GIVE YOUR COMMENT BELOW

QUESTION 18

What is the difference between creating String as new() and literal?
Solution :
When we create string with new() Operator, it’s created in heap and not added into string pool while String created using literal are created in String pool itself which exists in PermGen area of heap.

String s = new String("Test");

does not  put the object in String pool , we need to call String.intern() method which is used to put  them into String pool explicitly. its only when you create String object as String literal e.g. String s = "Test" Java automatically put that into String pool.

            <PREVIOUS || Main Page || NEXT >
              GIVE YOUR COMMENT BELOW

QUESTION 17

What is immutable object? Can you write immutable object?
Solution :
Immutable classes are Java classes whose objects can not be modified once created. Any modification in Immutable object result in new object. For example is String is immutable in Java. Mostly Immutable are also final in Java, in order to prevent sub class from overriding methods in Java which can compromise Immutability. You can achieve same functionality by making member as non final but private and not modifying them except in constructor.  

<PREVIOUS || Main Page || NEXT >
        GIVE YOUR COMMENT BELOW

QUESTION 16

Which two method you need to implement for key Object in HashMap ?

In order to use any object as Key in HashMap, it must implements equals and hashcode method in Java. Read How HashMap works in Java  for detailed explanation on how equals and hashcode method is used to put and get object from HashMap
    
                   <PREVIOUS || Main Page || NEXT >
                    GIVE YOUR COMMENT BELOW

Sunday, 17 May 2015

Transport Management System in java

Outstanding java program for transport management system Contains all the information for bus route ,bus information,driver information,passenger information,Ticket information and many more download the source code.
you have to add your own data base.

This program is Transport Management System called AwetraSoft.
It allows user to add driver, sell tickets and other cool features. Try it out.


Sample output :








Click Here to download source code


Note :
  1. After Click on "Click Here" please wait for 5 sec and than click on skip ad button to download the code
  2. If you like the program Please do comment below so i will post more program like that
  3. Use these information to run program                                                                     Default User Name: AwetraSoft    
                                                     Password : admin
                                                     Default position: Manager.

Friday, 15 May 2015

Student Registration System in java

Outstanding program for those who want to submit there final project.This project will store the data of student and there registered courses and all the information that is needed for registration like credit hour ,fees per credit hour,lecture time and many more thing you can see in the sample output below

The following java project contains the java source code and java examples used for student registration system. This program is what i have to created on a College Class for my Second semester in Java . This works as a registration system and a student information.
The source code and files included in this project are listed in the project files section, please make sure whether the listed source code meet your needs there
Sample output:










Click Here to download the code for Student registration System
Note :
  1. After Click on "Click Here" please wait for 5 sec and than click on skip ad button to download the code
  2. If you like the program Please do comment below so i will post more program like that 


Wednesday, 13 May 2015

ATM operation in java code


The following source code and examples are used for ATM Operations. There is a admin menu for creating,deleting,updating,searching a user account.
The source code and files included in this project are listed in the project files section, please make sure whether the listed source code meet your needs there


Click Here to download ATM java source code
Note :
  1. After Click on "Click Here" please wait for 5 sec and than click on skip ad button to download the code
  2. If you like the program Please do comment below so i will post more program like that 

Monday, 11 May 2015

File I/O Streams



You can write data to a file instead of the computer screen. You can write certain data to a file while still putting other data on the screen. Or you may need access to multiple files simultaneously. Or you may want to query the user for input rather than accepting it all on the command line. Or maybe you want to read data out of a file that's in a particular format. In Java all these methods take place as streams. < > Using File I/O streams. The System.out.println() statement we've been using all along is an implementation of Streams.

A program that writes a string to a file

In order to use the Java file classes, we must import the Java input/output package (java.io) in the following manner

import  java.io.*;

Inside the main method of our program, we must declare a FileOutputStream object. In this case, we wish to write a string to the file, and so we create a new PrintStream object that takes as its constructor the existing FileOutputStream. Any data we send from PrintStream will now be passed to the FileOutputStream, and ultimately to disk. We then make a call to the println method, passing it a string, and then close the connection.
Source Code
/*
* FileOutput
* Demonstration of FileOutputStream and PrintStream classes
*/

import java.io.*;

class FileOutput 


public static void main(String args[])

FileOutputStream out; // declare a file output object
PrintStream p; // declare a print stream object

try
{
// Create a new file output stream connected to "myfile.txt"
out = new FileOutputStream("myfile.txt");

// Connect print stream to the output stream
p = new PrintStream( out );

p.println ("This is written to a file myFile.txt");

p.close();
}
catch (Exception e)
{
System.err.println ("Error writing to the file myFile.txt");
}
}
}

Interactively communicating with the user

Program asking  the user for their name and then prints a personalized greeting.
Source Code
import java.io.*;

class PersonalHello {

  public static void main (String args[])
    {
    
      byte name[] = new byte[100];
      int nr_read = 0;

      System.out.println("Your name Please?");
      try {
        nr_read = System.in.read(name);
        System.out.print("Hello ");
        System.out.write(name,0,nr_read);
      }
      catch (IOException e) {
        System.out.print("I did not get your name.");
      }
      
    }
    
}
In code that does any significant input or output you'll want to begin by importing all the various java.io classes. import.java.io.*; Most of the reading and writing you do in Java will be done with bytes. Here we've started with an array of bytes that will hold the user's name.
First we print a query requesting the user's name. Then we read the user's name using the System.in.read() method. This method takes a byte array as an argument, and places whatever the user types in that byte array. Then, like before, we print "Hello." Finally we print the user's name.
The program doesn't actually see what the user types until he or she types a carriage return. This gives the user the chance to backspace over and delete any mistakes. Once the return key is pressed, everything in the line is placed in the array.

Reading Numbers

Often strings aren't enough. A lot of times you'll want to ask the user for a number as input. All user input comes in as strings so we need to convert the string into a number.
The getNextInteger() method that will accept an integer from the user. Here it is:
  static int getNextInteger() {
  
    String line;
  
    DataInputStream in = new DataInputStream(System.in);
    try {
      line = in.readLine();
      int i = Integer.valueOf(line).intValue();
      return i;
    }
    catch (Exception e) {
      return -1;
    }
       
  } // getNextInteger ends here

Reading Formatted Data

It's often the case that you want to read not just one number but multiple numbers. Sometimes you may need to read text and numbers on the same line. For this purpose Java provides the StreamTokenizer class.
Writing a text file
Sometimes you want to save your output in a  file. To do this we'll need to learn how to write data to a file. 
Source Code
// Write the Fahrenheit to Celsius table in a file

import java.io.*;

class FahrToCelsius  {

  public static void main (String args[]) {

    double fahr, celsius;
    double lower, upper, step;

    lower = 0.0;    // lower limit of temperature table
    upper = 300.0;  // upper limit of temperature table
    step  = 20.0;   // step size

    fahr = lower;
  
    try {

      FileOutputStream fout =  new FileOutputStream("test.out");

      // now to the FileOutputStream into a PrintStream
      PrintStream myOutput = new PrintStream(fout);
  
      while (fahr <= upper) {  // while loop begins here
        celsius = 5.0 * (fahr-32.0) / 9.0;
        myOutput.println(fahr + " " + celsius);
        fahr = fahr + step;
      } // while loop ends here
  
    }  // try ends here
    catch (IOException e) {
      System.out.println("Error: " + e);
      System.exit(1);
    }
  
  } // main ends here

}
There are only three things necessary to write formatted output to a file rather than to the standard output:
  1. Open a FileOutputStream using a line like
    FileOutputStream fout =  new FileOutputStream("test.out");
    This line initializes the FileOutputStream with the name of the file you want to write into.
  2. Convert the FileOutputStream into a PrintStream using a statement like
    PrintStream myOutput = new PrintStream(fout);
    The PrintStream is passed the FileOutputStream from step 1.
  3. Instead of using System.out.println() use myOutput.println()System.out and myOutput are just different instances of the PrintStream class. To print to a differentPrintStream we keep the syntax the same but change the name of the PrintStream.

Reading a text file

Now that we know how to write a text file, let's try reading one. The following code accepts a series of file names on the command line and then prints those filenames to the standard output in the order they were listed.
// Imitate the Unix cat utility

import java.io.*;

class cat  {

  public static void main (String args[]) {
  
  String thisLine;

  //Loop across the arguments
  for (int i=0; i < args.length; i++) {
 
  //Open the file for reading
  try {
    FileInputStream fin =  new FileInputStream(args[i]);

    // now turn the FileInputStream into a DataInputStream
    try {
      DataInputStream myInput = new DataInputStream(fin);
  
      try {
        while ((thisLine = myInput.readLine()) != null) {  // while loop begins here
          System.out.println(thisLine);
        } // while loop ends here
      }
      catch (Exception e) {
       System.out.println("Error: " + e);
      }
    } // end try
    catch (Exception e) {
      System.out.println("Error: " + e);
    }
  
   } // end try
   catch (Exception e) {
    System.out.println("failed to open file " + args[i]);
    System.out.println("Error: " + e);
  }
  } // for end here
  
  } // main ends here

}
  

Saturday, 9 May 2015

Scientific calculator in java code


The following java project contains the java source code and java examples used for a calculator with trigonometric functions. Its a calculator with the following functions: +,-,/,x,M+,M-,M,Mc,sin,tan,cos,square root,square with/without decimal in radians/degrees.

The source code and files included in this project are listed in the project files section, please make sure whether the listed source code meet your needs there.
This program will be helpful for final year students,this program include the GUI that looks and feel good .




Click Here to download the Scientific Calculator
Note :
  1. After Click on "Click Here" please wait for 5 sec and than click on "skip ad" button to download the code
  2. If you like the program Please do comment below so i will post more program like that 


Saturday, 2 May 2015

QUESTION 15

Which of the following lines will print false?

1.    public class MyClass
2.    {
3.        static String s1 = "I am unique!";
4.        public static void main(String args[])
5.        {
6.            String s2 = "I am unique!";
7.            String s3 = new String(s1);
8.            System.out.println(s1 == s2);
9.            System.out.println(s1.equals(s2));
10.            System.out.println(s3 == s1);
11.            System.out.println(s3.equals(s1));
12.            System.out.println(TestClass.s4 == s1);
13.        }
14.    }
15.
16.    class TestClass
17.    {
18.        static String s4 = "I am unique!";
19.    }
------------------------------------------------------------------------------------
A. Lines 10 and 12
B. Line 12 only
C. Line 8 and 10
D. None of these


            <PREVIOUS || Main Page || NEXT >
GIVE YOUR ANSWER IN THE COMMENT BELOW

QUESTION 14

What is displayed when the following code is compiled and executed?

String s1 = new String("Test");
String s2 = new String("Test");
if (s1==s2)
          System.out.println("Same");
if (s1.equals(s2))
          System.out.println("Equals");

------------------------------------------------------------------------------------
A. Same
B. Equals
C. The code compiles, but nothing is displayed upon execution. 
D. The code fails to compile.

          <PREVIOUS || Main Page || NEXT >
GIVE YOUR ANSWER IN THE COMMENT BELOW

QUESTION 13

What is displayed when the following is executed?

class Parent
{
    private void method1()
    {
        System.out.println("Parent's method1()");
    }
    public void method2()
    {
        System.out.println("Parent's method2()");
        method1();
    }
}
class Child extends Parent
{
    public void method1()
    {
        System.out.println("Child's method1()");        
    }
    public static void main(String args[])
    {
        Parent p = new Child();
        p.method2();
    }
}
--------------------------------------------------------------------------------------
A. Compile time error 
B. Run time error 
C. prints : Parent's method2()
          Parent's method1() 
D. prints : Parent's method2() 
          Parent's method1() Child's method1()

<PREVIOUS || Main Page || NEXT >
GIVE YOUR ANSWER IN THE COMMENT BELOW

QUESTION 12

What will happen when you attempt to compile and run the following code snippet?

String str = "Java";
    StringBuffer buffer = new StringBuffer(str);
    
    if(str.equals(buffer))
    {
        System.out.println("Both are equal");
    }
    else
    {
        System.out.println("Both are not equal");
    }
-----------------------------------------------------------------------------------
A. It will print - Both are not equal
B. It will print - Both are equal
C. Compile time error as you can not use equals for objects of different classes
D. Runtime error as you can not use equals for objects of different classes
E. None of these

<PREVIOUS || Main Page || NEXT >
GIVE YOUR ANSWER IN THE COMMENT BELOW

QUESTION 11

What will happen when you attempt to compile and run the following code?

public class MyThread extends Thread
{
    String myName;
    MyThread(String name)
    {
        myName = name;
    }
    public void run()
    {
        for(int i=0; i<100;i++)
        {
            System.out.println(myName);
        }
    }
    public static void main(String args[])
    {
        try
        {
            MyThread mt1 = new MyThread("mt1");
            MyThread mt2 = new MyThread("mt2");
            mt1.start();
            // XXX
            mt2.start();
        }
        catch(InterruptedException ex)
        {
        }
    }
}
----------------------------------------------------------------------------------
A. The above code in its current condition will not compile. 
B. In order to make the MyThread class prints "mt1" (100 times) followed by "mt2" (100 times), mt1.join(); can be placed at //XXX position.
C. In order to make the MyThread class prints "mt1" (100 times) followed by "mt2" (100 times), mt1.sleep(100); can be placed at //XXX position.
D. In order to make the MyThread class prints "mt1" (100 times) followed by "mt2" (100 times), mt1.run(); can be placed at //XXX position.
E. In order to make the MyThread class prints "mt1" (100 times) followed by "mt2" (100 times), there is no need to write any code.

<PREVIOUS || Main Page || NEXT >
GIVE YOUR ANSWER IN THE COMMENT BELOW