E) none of the above, a run-time crror aises because z is a float and 5 7 1o is
ID: 3590081 • Letter: E
Question
Explanation / Answer
15. System.out.println("" + x + y); //This is an empty string concatenated with the value of x, concatenated with the value of y.
So, the answer is: B) 105
16. A. String name = "George Bush"; //Creates a variable name, and is assigned a String literal.
B. String name = new String("George Bush"); //Creates an object of type String, and is initialized with specified String.
C. String name = "George" + " " + "Bush"; //Creates a variable name, and is assigned the concatenation of 3 strings.
D. String name = new String("George" + " " + Bush"); //Creates an object of type String, and is initialized with concatenation of 3 string literals.
Everything works fine.
So, the answer is E. Any of the above would work.
17. Assignment statement, assume like:
int a = 10; //This works perfectly fine.
int a = 10 //This leads to a syntax error, as we missed the semicolon.
short a = (short)1000000; //This leads to a logical error. Everything works fine, but produces unexpected output.
18.
public static void main(String[] args)
{
//To keep it simple I prefer directly writing 3 print statements.
System.out.println("*");
System.out.println("* * *");
System.out.println("* * * * *");
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.