Defining class and object

Posted by Stephen thangaraj at 19:01

class students
{
        private int sno;
        private String sname;
        public void setstud(int no,String name)
        {
                sno = no;
                sname = name;
        }
        public void dispstud()
        {
                System.out.println("Student No : " + sno);
                System.out.println("Student Name :" + sname);
        }
        public static void main(String args[])
        {
                if(args.length < 2)
                {
                        System.out.println("Invalid Arguments");
                        System.exit(0);
                }
                students s = new students();
                int no = Integer.parseInt(args[0]);
                String name = args[1];
                s.setstud(no,name);
                s.dispstud();
        }
}


If you enjoyed this post and wish to be informed whenever a new post is published, then make sure you subscribe to my regular Email Updates. Subscribe Now!


Kindly Bookmark and Share it:

YOUR ADSENSE CODE GOES HERE

0 comments:

Have any question? Feel Free To Post Below:

 

© 2011. All Rights Reserved | Interview Questions | Template by Blogger Widgets

Home | About | Top