🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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?

  1. A.Because square returns an int
  2. B.Because all methods in Java are static
  3. C.Because square is declared static, so it belongs to the class
  4. 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 →