Question: 1. Given the code below: public class CmdLine { public static void main(String[] args) { String str = ; str = args[0] + args[1] +
1.
Given the code below:
public class CmdLine { public static void main(String[] args) { String str = ""; str = args[0] + args[1] + args[2]; System.out.print(str); } } What is the output of the following command?
java CmdLine W "X Y" Z
Group of answer choices
WXY
WX YZ
WXYZ
W"X Y"
W"X
q2.
What will the following code print out when it is run?
Scanner fileIn = new Scanner(new File("fileIn.txt")); int count = 0; while (fileIn.hasNextLine()) { String str = fileIn.nextLine().trim(); if (str.indexOf('?') >= 0) { count++; } } System.out.print(count); Contents of fileIn.txt:
Is this a question? ?Is this also a question? How? about? this? And? this?
Group of answer choices
7
0
8
4
6
q3.
Which of the following code segments will correctly create an instance of an Item class?
public class Item { private String name; private double price; public Item(double a, String b) { name = b; price = a; } } Group of answer choices
Item chair = new Item(29.95, "Chair");
new Item chair = Person("Chair", 29.95); Item chair = ("Chair", 29.95); Item chair = new Item("Chair", 29.95); Item chair("Chair", 29.95);
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
