Question: QUESTION 1 What ( if anything ) is the output of the following code: System.out.println ( Hello , Dave. How have you been? )

QUESTION 1
What (if anything) is the output of the following code:
System.out.println("Hello,
Dave. How have you been?");
Hello,
Dave. How have you been?
Hello,
Dave. How have you been?
Hello, Dave. How have you been?
It will not output anything as there is a syntax error that will produce a compiler bug.
8 points
QUESTION 2
Which of the following is not a valid example of a variable declaration and assignment:
int x =3, y =7;
double price1=10.55, price2=4.33;
int x =5.3;
char c1='x';
8 points
QUESTION 3
What will be the output of the following code:
System.out.println("We went to the movie.
It was very fun.
However, I would have preferred to go bowling instead.");
We went to the movie. It was very fun. However, I would have preffered to go bowling instead.
We went to the movie.
It was very fun.
However, I would have prefferred to go bowling instead.
We went to the movie.
It was very fun.
However, I would have prefferred to go bowling instead.
It will not output anything as it will generate a compiler error.
8 points
QUESTION 4
What (select all correct answers) is wrong with the following code:
final double PI =3.14;
int x =17;
boolean isSafe = false;
PI =3.1415;
double area = PI *12.3;
y = x;
One of the variables has been declared more than once.
One of the statements attempts to modify a constant.
One of the variables contains an illegal identifier.
One of the variables has not been declared.
Nothing is wrong with the code example.
One of the variable is assigned the wrong type of data when it is initialized.
8 points
QUESTION 5
Which of the following is not a valid variable declaration and initialization:
char firstLetter ='a';
long bigNumber =383298147085L;
double PRICE =15.3;
boolean isTrue =0;
8 points
QUESTION 6
If you wanted to produce the following output, which (select all correct answers) of the following code examples would work:
Hello
World!
System.out.println("Hello");
System.out.println("World!");
System.out.println("Hello
World!");
System.out.println("Hello
World!");
String s1= "Hello", s2="World!", s3="
";
System.out.println(s1+ s3+ s2);
String s1= "Hello";
String s2= "World";
System.out.println(s1+ s2);
8 points
QUESTION 7
Which of the following is the correct way to declare a constant variable:
final double radiusOfTire =17.2;
final PI =3.1415;
contant double RADIUS_OF_TIRE =15.3;
double PI =3.1415;
8 points
QUESTION 8
What (if anything) is wrong with the following code:
int xPosition, yPosition;
xPosition =53;
yPosition =37;
int xPosition = yPosition;
The variable yPosition is being assigned a value of the incorrect type.
Nothing is wrong with this code.
The variable xPosition is being declared twice.
Multiple variables cannot be declared on the same line.
Variables of the type int cannot be assigned a literal value.
8 points
QUESTION 9
What (if anything) will be the output of the following code:
System.out.println("My friend Bill said, "I really love ice cream!"");
My friend Bill said, "I really love ice cream!"
"My friend Bill said, "I really love ice cream!""
My friend Bill said,
"I really love ice cream!"
It will not output anything as it contains a syntax error and will cause a compiler error.
8 points
QUESTION 10
Which (select all correct answers) of the following Java statements are valid:
final String MESSAGE = "I said, "Go away!"";
final char c ="c";
final double PI =3.14;
final int students;
8 points
QUESTION 11
The boolean data type can only store one of two different values, which are the Java reserved words true and false.
True
False
4 points
QUESTION 12
In Java was use a single equal-sign, '=', to assign a value to a variable.
True
False
4 points
QUESTION 13
Java's integer data type is unsigned, which means it can only store positive values.
True
False
4 points
QUESTION 14
The char data type is capable of storing multiple Unicode characters.
True
False
4 points
QUESTION 15
Among other uses, the plus-sign '+' is the String concatenation operator which can be used to combine multiple String variables or String literals into a single String.
True
False
4 points
QUESTION 16
In Java, variable assignment is left to right. That is the variable on the right will receive the value of the variable or literal value on the left.
True
False
4 points
QUESTION 17
The following piece of code is a valid declaration and initialization:
long populationOfEarth =7257000000;
True
False
4 points
QUESTION 18
To declare a variable as constant, it is necessary to use the Java reserved word constant.
True
False
4 points
QUESTION 19
To create a String that contains special characters such as a newline, a tab, or quotation marks it is necessary to use an escape sequence.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!