Question: (a) (b) (c) What are static methods? Explain the difference between things that belong to the class itself and those that belong to an
(a) (b) (c) What are static methods? Explain the difference between things that belong to the class itself and those that belong to an instance of the class. What is a Singleton class? How is it implemented in java? (2 marks) (4 marks) When you try to compile the class Q5C below the compiler will generate the following error message: non-static variable num2 cannot be referenced from a static context. Explain why it generates this message. Rewrite it so that it does not give a compile error. class Q5C{ private static int num1 = 0; private int num2; public Q5C(int n){num2 = n;} public static void modNum2(int n){num2 = n;} } (4 marks) Total (10 marks) Windo
Step by Step Solution
There are 3 Steps involved in it
a Static Methods Definition Static methods are methods that belong to the class itself rather than i... View full answer
Get step-by-step solutions from verified subject matter experts
