You are here:   HomeJava ProgrammingClasses in JavaInner Class Java Example
by Dinesh Thakur Category: Classes

 

class student

             {
                  int roll,hindi,eng;
                  String nme;
                  void setdata(int p, String q, int r, int s)
                    {
                       roll=p;
                       nme=q;
                       hindi=r;
                       eng=s;
                    }
                       void showdata()
                           {
                               System.out.println("Roll number :"+roll);
                               System.out.println("Students name :"+nme);
                               System.out.println("English marks :"+eng);
                           }
             };
                  class totobject
                   {
                       public static void main(String args[])
                     {
                              student k= new student();
                              k.setdata(101,"Ravinder Chalana",65,80);
                              k.showdata();
                              total(k);
                         }
                             static void total(student m)
                                   {
                                       int tot;
                                       tot=m.hindi+m.eng;
                                       System.out.println("Total marks area:"+tot);
                                   }
                  }
Passing student Object as Parameter in Java Example