Results 1 to 4 of 4

Thread: Object for static class

  1. #1
    Junior Member
    Join Date
    Sep 2007
    Answers
    1

    Object for static class

    Can we create object for satic class?
    if yes plz show with some code based example?


  2. #2
    Contributing Member
    Join Date
    Sep 2006
    Answers
    962

    Re: Object for static class

    yes you can create an object of a static class. But there is no meaning. Because we used an static class when we dont want to create an object. You can used these data members and methods without create
    an object. Otherwise u directly create an object without used the static class..Can you clear now????

    --------------------
    suresh


  3. #3
    Junior Member
    Join Date
    Aug 2008
    Answers
    2

    Re: Object for static class

    Generally we can have static inner classes only.


  4. #4

    Re: Object for static class

    Yes we can create object for static classes. But not necessary.

    Ex:
    class Sample
    {
    public static void main(String args[])
    {
    Math m=new Math();
    System.out.println(m.sqrt(120));//with help of object
    System.out.println(Math.sqrt(120));//with out object
    }


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact