Java Programming
Accenture Technical 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

Quick AnswerThe correct answer is Test.display();, new Test().display(); because it directly addresses the core logic of Java Programming.

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

Related Accenture Java Programming questions

Practice more Accenture Java Programming questions

PrimerPrep has 1400+ practice questions, 2026 simulations and coding hands-on — all free.

Watch Walkthroughs!