Which code should be inserted at line 1 of Demo.java to compile and run Demo to print "pizzapizza"?

Given a class Repetition:
1. package utils;
2.
3. public class Repetition {
4. public static String twice(String s) { return s + s; }
5. }
and given another class Demo:
1. // insert code here
2.
3. public class Demo {
4. public static void main(String[] args) {
5. System.out.println(twice(“pizza”));
6. }

7. }
Which code should be inserted at line 1 of Demo.java to compile and run Demo to print
“pizzapizza”?

Given a class Repetition:
1. package utils;
2.
3. public class Repetition {
4. public static String twice(String s) { return s + s; }
5. }
and given another class Demo:
1. // insert code here
2.
3. public class Demo {
4. public static void main(String[] args) {
5. System.out.println(twice(“pizza”));
6. }

7. }
Which code should be inserted at line 1 of Demo.java to compile and run Demo to print
“pizzapizza”?

A.
import utils.*;

B.
import utils.Repetition.*;

C.
static import utils.Repetition.*;

D.
static import utils.*;

E.
static import utils.Repetition.twice;

F.
import utils.Repetition.twice();

G.
import static utils.Repetition.twice;



Leave a Reply 0

Your email address will not be published. Required fields are marked *