What will be outputted by the following code? System.out.println(5 + \"5\" + 5);
ID: 3704967 • Letter: W
Question
What will be outputted by the following code?
System.out.println(5 + "5" + 5);
510
555
60
105
15
4 points
QUESTION 17
A class must implement all abstract methods inherited from a parent class or from an interface, or else it must be declared abstract itself.
True
False
2 points
QUESTION 18
Which of the following is the correct way to declare the main method in Java?
public static void main()
int main(int argc, char **argv)
private static void main(String[] args)
public static void main(String[] args)
4 points
QUESTION 19
Which keyword is used in Java to mark an instance field (also known as a member or an attribute) as a constant?
abstract
const
static
final
4 points
QUESTION 20
What will be outputted by the following code?
System.out.println(72 + 72 + "72");
14472
216
The compilation of this code will fail.
727272
72
4 points
QUESTION 21
Place the following data types in order from smallest range to largest range of values.
- 1. 2. 3. 4.
long
- 1. 2. 3. 4.
byte
- 1. 2. 3. 4.
int
- 1. 2. 3. 4.
short
4 points
QUESTION 22
What changes will make this code compile?
class X {
X() { }
private void one() { }
}
public class Y extends X {
Y() { }
private void two() { one(); }
public static void main(String[] args) {
new Y().two();
}
}
Adding the protected modifier to the X() constructor
Removing the private modifier from the two() method
Removing the Y() constructor
Adding the public modifier to the declaration of class X
Changing the private modifier on the declaration of the one() method to protected
4 points
QUESTION 23
Which of the following programs contains no errors? (Study your choices carefully!)
package edu.jsu.mcis.cs232;
import java.util.String;
public class Hello {
public static void main(String[] args) {
System.out.println("Hello, world!");
}
}
package edu.jsu.mcis.cs232;
include java.lang.String;
public class Hello {
public static void main(String[] args) {
System.out.println("Hello, world!");
}
}
package edu.jsu.mcis.cs232;
public class Hello {
public static void main(String[] args) {
System.out.println("Hello, world!");
}
}
import java.lang.String;
package edu.jsu.mcis.cs232;
public class Hello {
public static void main(String args[]) {
String str = "Hello, world!";
System.out.println(str);
}
}
4 points
QUESTION 24
By declaring a variable to be of type auto, Java will automatically deduce the type of the variable from the type of the value with which it is initialized.
True
False
2 points
510
555
60
105
15
Explanation / Answer
16) 555 17) True 18) public static void main(String[] args) 19) final 20) 14472 21) byte - short - int - long 22) Changing the private modifier on the declaration of the one() method to protected 23) package edu.jsu.mcis.cs232; include java.lang.String; public class Hello { public static void main(String[] args) { System.out.println("Hello, world!"); } } 24) False
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.