Question: What is true of the following code? (Choose two.) A. As written, the code prints one line. B. As written, the code prints two lines.
What is true of the following code? (Choose two.)
![3: public static void main(String[] args) { 4: var prefix= "r"; 5:](https://dsd5zvtm8ll6.cloudfront.net/images/question_images/1707/4/6/2/62765c5cfe3c12d71707462627214.jpg)
A. As written, the code prints one line.
B. As written, the code prints two lines.
C. As written the code does not compile.
D. If line 7 is uncommented, the code prints one line.
E. If line 7 is uncommented, the code prints two lines.
F. If line 7 is uncommented, the code does not compile.
3: public static void main(String[] args) { 4: var prefix= "r"; 5: var pets = List.of("rabbit", "snake", "turtle"); 6: 7: 8: 9: 10: } // prefix = "t"; pets.forEach (p -> { if (p.startsWith(prefix)) System.out.println(p); } );
Step by Step Solution
3.44 Rating (157 Votes )
There are 3 Steps involved in it
The code in the image is written in Java and uses the lambda expression inside forEach to iterate ov... View full answer
Get step-by-step solutions from verified subject matter experts
