Java Programming
Accenture PrimermediumJava Programming03 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

A static method can be called using the class name (Test.display()) or via an instance.

Related Accenture Java Programming questions

Practice more Accenture Java Programming questions

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