Monday, December 22, 2014

Java using program



Program 1

package com.jbt;
import java.io.Serializable;
public class Employee extends superEmployee
{
public String firstName;
private static final long serialVersionUid = 5462223600l;
}
class superEmployee implements Serializable
{
public String lastName;
static  String companyName;
transient  String address;
static transient String companyCEO;
}

Program 2

package com.jbt;
import java.io.*;
public class Deserialization Class
{
public static void main(String[] args)
{
Employee emp = null;
try
{
FileInputStream fileIn = new FileInputStream("./employee.txt");
ObjectInputStream in = new ObjectInputStream(fileIn);
emp = (Employee) in.readObject();
in.close();
fileIn.close();
}
catch (IOException i)
{
i.printStackTrace();
return;
}
catch (ClassNotFoundException c)
{
System.out.println("Employee class not found");
c.printStackTrace();
return;
}
System.out.println("Deserializing Employee...");
System.out.println("First Name of Employee: " + emp.firstName);
System.out.println("Last Name of Employee: " + emp.lastName);
System.out.println("Company Name: "+emp.companyName);
System.out.println("Company CEO: "+emp.companyCEO);
System.out.println("Company Address: "+emp.address);
System.out.println("Education: "+emp.education);
   }
}

Program 3

class interface example two implements interface two
{
public void methhod()
{
System.out.println(var);
}
 }
interface interfaceTwo
{
public final int var = 9;
public abstract void methhod();
}

Program 4

class interfaceexampletwo extends interfaceexamplethree
{
public void methhod()
{
System.out.println(var);
}
}
interface interfaceTwo
{
public final int var = 9;
public abstract void methhod();
}
abstract class InterfaceExampleThree implements interfaceTwo
{
}

No comments:

Post a Comment