In the following code suppose that f is an instance of Foo A

In the following code, suppose that f is an instance of Foo. Answer Question 2. class Foo {static int x; static int s; void imethod () {static void smethod {} Which of the following statements is incorrect? f.smethod(); System.out.println(Foo.s); Foo. imethod(); System.out.println(Foo.x);

Solution

Foo.imethod() is incorrect as a method can not be evoked without creating an instance of a class.

 In the following code, suppose that f is an instance of Foo. Answer Question 2. class Foo {static int x; static int s; void imethod () {static void smethod {}

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site