Java Programming
primer-original-v2mediumJava Programming03 Class And Objects, Date Apiprimer-original-v2

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();

Explanation

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

This question has been retained as-is due to its unique context.

Related Java Programming questions

Practice more Java Programming questions

PrimerPrep has independently reviewed practice questions and coding exercises — all free.