Multiple choice technology programming languages

True or False. Is Foo.Print() a valid statement? Given a class Foo and it has a function public void Print (); Foo f = new Foo (); Foo.Print ();

  1. True

  2. False

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

The statement 'Foo.Print()' is incorrect because Print() is an instance method (not static). Instance methods must be called on an object instance, not the class name. The correct syntax would be 'f.Print();' where 'f' is the instance. Class-name syntax (Foo.Print()) is only valid for static methods.