Accenture Java Programming Practice Question
For the below code, what are the valid ways to invoke display method in the main method. public class Test { public static void display(){ } } public class Main { public static void main(String a[]){ //Invoke the display method } }Answer options
A
Test.display();
B
new Test().display();
C
display();
Correct answer: Test.display();, new Test().display();
Explanation
A static method can be called using the class name (Test.display()) or via an instance.