BPJ 01-03 Quiz
-
Write a statement to print out the following:
Doc Mo said, "I hope you studied."
-
How do you run a main method that is in another class?
public class Q2 { // in file "Q2.java"
public static void main() { /* do something */ }
}
public class Main { // in file "Main.java"
public static void main(String[] args) {
// What goes here?
}
}
-
Comment on the legality of each of these lines of code:
double alpha = 314;
int beta = 28.18;
String gamma = "alpha = "+alpha;
double delta = 3_141_592 * 10^-6;
-
Declare but do not initialize a String variable called
q5
. -
Write two different kinds of comments.
- Type I
- Type II
-
Given
String s = "U do well"
, what iss.substring(1,4)
? Put your answer in quotes. -
Type the the output from the following code exactly.
String k = "Alan Turing";
int n = k.length();
System.out.print(n);
System.out.println(k.substring(8));