← Quiz: Java Methods: all 10 questions
Quiz: Java Methods · Question 10 of 10
Inside class Main, why can main call square(7) without creating an object?
Inside class Main, why can main call square(7) without creating an object?
- A.Because square returns an int
- B.Because all methods in Java are static
- C.Because square is declared static, so it belongs to the class
- D.Because main is public
Answer & explanation
Correct answer: Because square is declared static, so it belongs to the class
A static method can call other static methods of its class directly. An instance method would need an object.
Can you get the rest right without peeking?
Take the timed Quiz: Java Methods quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →