[ test_product.java ]
import java.io.*;class product
{
String p_name,m_name;
int p_code;
product()
{
System.out.println("CONSTRUCTOR CALLED....\n");
p_code=0;
}
//inisialization block
{
System.out.println("INISIALIZATION BLOCK CALLED....\n");
}
static
{
System.out.println("STATIC BLOCK CALLED....\n");
}
public void get_data() throws IOException
{
System.out.println(".....GETTING DATA FROM USER.....\n\n");
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.print("\tEnter Product Code : ");
p_code=Integer.parseInt(br.readLine());
System.out.print("\tEnter Product Name : ");
p_name=br.readLine();
System.out.print("\tEnter Manufacturar Name : ");
m_name=br.readLine();
}
public void display_data()
{
System.out.println("\n\n.....Displaying data....\n\n");
System.out.println("\tProduct Code : " + p_code);
System.out.println("\tProduct Name : " + p_name);
System.out.println("\tManufacturar Name : " + m_name);
}
}
class test_product
{
public static void main(String args[]) throws IOException
{
product obj;
obj=new product();
obj.get_data();
obj.display_data();
}
}
GoTo Command Prompt(Win + R)
ReplyDeleteHOW TO COMPILE
javac c:\yourdir\test_product.java
HOW TO EXECUTE
java c:\yourdir\test_product
thanks bro
ReplyDelete