🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Java Classes and Objects: all 10 questions

Quiz: Java Classes and Objects · Question 5 of 10

Why can't a static method use an instance field directly?

Why can't a static method use an instance field directly?

  1. A.Static methods are slower
  2. B.It runs without any object, so there is no "this" to read the field from
  3. C.Instance fields are always private
  4. D.Java forbids static methods
Answer & explanation

Correct answer: It runs without any object, so there is no "this" to read the field from

Instance fields belong to objects; a static method isn't called on an object.

Can you get the rest right without peeking?

Take the timed Quiz: Java Classes and Objects quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →