Ask Experts Questions for FREE Help !
Ask
    Midya's Avatar
    Midya Posts: 1, Reputation: 1
    New Member
     
    #1

    Jun 19, 2012, 11:11 AM
    java
    public class Over {
    public int stack(int j, int k) { return j + k; }
    public int stack(int m) {
    return m * m;
    }
    public int stack(float f) {
    return (int)f * 5;
    }
    public static void main(String args[]) {
    int n = 3;
    float f = 3;
    Over o = new Over();
    System.out.println("" + o.stack(n, n));
    System.out.println("" + o.stack(n));
    System.out.println("" + o.stack(f));
    }
    }
    what is Over o = new Over () do? What is happen if we don't use it?
    slapshot_oi's Avatar
    slapshot_oi Posts: 1,537, Reputation: 589
    Ultra Member
     
    #2

    Jun 19, 2012, 11:29 AM
    Class definition:
    [CODE=Java]
    public class Over {
    public int stack(int j, int k) { return j + k; }
    public int stack(int m) {
    return m * m;
    }
    public int stack(float f) {
    return (int)f * 5;
    }
    public static void main(String args[]) {
    int n = 3;
    float f = 3;
    Over o = new Over();
    System.out.println("" + o.stack(n, n));
    System.out.println("" + o.stack(n));
    System.out.println("" + o.stack(f));
    }
    }[/CODE]

    This code
    [CODE=Java]Over o = new Over();[/CODE]
    Instantiates (creates in the heap of memory) an object of the class Over.

Not your question? Ask your question View similar questions

 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.


Check out some similar questions!

Java [ 3 Answers ]

Please will you help me with these questions... where can I find a great site that will help me answer these... 1/ Who developed Java and when? 2/ What are some unique features of Java? 3/ Is java used for websites or stand alone programs? 4/ What does it mean when I say java is an "object...

Something about java [ 1 Answers ]

Halo, I want to ask something about java question, some question had confuse, I need some hints, someone help me please, thank you! Calculate the value of π from the infinite series. Π = 4 – 4/3 +4/5 - 4/7 + 4/9 - 4/11 + …… Print a table that shows the value of π using...

Java [ 4 Answers ]

We can not instantiate an abstract class. But we can write a constructor in abstract class. If we are not able to create an object, then how and why is it possible to create a constructor in an abstract class?


View more questions Search