Accenture Java Programming Practice Question
Given classes defined in two different files: 1. package p1; 2. public class Test { 3. public static void display(String [] a) { /* some code */ } 4. } 1. package p2; 2. public class TestMain { 3. public static void main(String[] args) { 4. String [] names = new String[10]; 5. // insert code here 6. } 7. } Identify the statement to be written in line 5 in class TestMain to call the display method of class Test.Answer options
A
p1.Test.display(names);
B
import p1.Test.*; display(names);
C
display(names);
D
p1.display(names);
E
TestMain cannot use methods in p1
Correct answer: p1.Test.display(names);
Explanation
Correct answer: p1.Test.display(names);.