Featured Post

Wednesday, May 10, 2017

java program to create employee class and set and get values using class methods



import java.util.Scanner;
class employee              /*employee.java*/
{
  int empno,salary;
  String ename;
  public void getdata()
  {
    Scanner s=new Scanner(System.in);
    System.out.println("enter empno,ename and salary");
    empno=s.nextInt();
    ename=s.next();
    salary=s.nextInt();
  }
  public void putdata()
  {
   System.out.println("employee number is "+empno);
   System.out.println("employee name is "+ename);
   System.out.println("employee salary is"+salary);

  }
}
 
   
class emp
{
   public static void main(String args[])
   {
     employee e1=new employee();
     e1.getdata();
     e1.putdata();    
     
    }
}

Output:
D:\cjuschools>javac employee.java
D:\cjuschools>java employee
enter empno,ename and salary
101
ashok
30000
employee number is 101
employee name is ashok
employee salary is 3000

  Next

oops through java,inheritance,interface,package,super keyword, program demonstrating the use of super keywork,abstract class,static,main,awt,swings,jtab,layout,panel,applet,param,Frame,JFrame, swingutilities.invokeLater,swingutilities.invokeanwait,multithreading,multiprocesing,start(),init() paint(),adapter class,inner class,annonymous inner class,outer class,packages,friendly, constrcutors,destructors,garbage collector,inheritance,encapusulation,abstraction,bytecode,compiler,interpreter,jdbc,jsp pages,exception handling

No comments:

Post a Comment