Which of the following can a class NOT be used for? Select one: a.a...
Which of the following can a class NOT be used for?
Select one:
a. a primitive type
b. a container for static methods
c. a container for static variables
d. a type for method parameters
e. a type for variables
Which one of the following Java technologies eliminates memory leaks?
Select one:
a. garbage collection
b. inheritance
c. just-in-time compilers
d. polymorphism
e. virtual machines
Consider the following Java program.
1 public class HelloWorld {
2 // My first program!
3 public static void main(String[] args) {
4 System.out.println("Hello, World!");
5 }
6 }
What starts on line 2?
Select one:
a. a statement
b. a package
c. a method definition
d. a comment
e. a class definition
Consider the following Java method.
public static void main(String[] args) {
System.out.println("Hello, Final!");
}
Which term best describes "String[] args"?
Select one:
a. actual parameter or argument
b. formal parameter
c. modifier
d. return type
e. superclass
Which of the following is NOT an effective strategy when your program does not work?
Select one:
a. Make random changes to code that you do not understand until it accidentally works.
b. Read through your code and figure out what it does step by step.
c. Check each error message generated by the compiler or IDE.
d. Add debugging statements to output information about the state of your program while it runs.
e. Use a debugger to pause your program while it is running so you can check its state.
What is the output of the following Java program?
import java.util.*;
class ArrayGames {
public static void main(String[] args) {
int[] a = {1,2,3,4,5};
System.out.println(a[1]);
}
}
Select one:
a. 1
b. 2
c. 3
d. 4
e. 5
Consider the following Java program.
1 public class HelloWorld {
2 // My first program!
3 public static void main(String[] args) {
4 System.out.println("Hello, World!");
5 }
6 }
What starts on line 3?
Select one:
a. a statement
b. a package
c. a method definition
d. a comment
e. a class definition
Consider the following Java method.
public static void main(String[] args) {
System.out.println("Hello, Final!");
}
Which term best describes '"Hello, Final!"'?
Select one:
a. actual parameter or argument
b. formal parameter
c. modifier
d. return type
e. superclass
Which of the following is NOT a valid identifier in Java?
Select one:
a. p
b. Public
c. public
d. public1
e. PuBlIc_oNe
What is the output of the following Java program?
class Sum {
static int sum = 0;
static void add() { sum++; }
public static void main(String[] args) {
for (int i = 0; i < 100; i++) add();
System.out.println(sum);
}
}
Select one:
a. 0
b. 9
c. 10
d. 99
e. 100
Unlock full access to Course Hero
Explore over 16 million step-by-step answers from our library
Subscribe to view answeracinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur
inia pulvinar tortor
inia pulvinar tortor nec facilisis. Pellen
fficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna.
, consectetur adipiscing elit. Nam lacinia pulvin
fficitur laoreet. Nam
lor sit amet, c
ng elit. Nam lacinia pulvinar tortor nec fac
ce dui lectus, congue vel laoreet
rem ipsum dolor sit amet, consectetur adipiscing elit. Na
consectetur
, consectetur adipiscing elit. Nam lacinia pulvin
ur laore