Java Programming
Accenture PrimermediumJava Programming3. Class And Objects, Date Api

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

Static methods can be invoked via class name or via an instance reference.

Related Accenture Java Programming questions

Practice more Accenture Java Programming questions

PrimerDumps has 1400+ primer questions, 2026 mocks and coding hands-on — all free.