Choice Questions.
In the following code, suppose that f is an instance of Foo. Answer Questions 1– 2.
class Foo {
int i; {实例方法}
static int s; {静态方法}
void imethod() { }
static void smethod() { }
}
Which of the following statements is incorrect?
();
int t = ();
();
();
Which of the following statements is incorrect? 静态方法:(参数)
();
();
();
();
Analyze the following code:
public class Test {
public static void main(String args[]) {
Test nc = new Test();
= ++;
}
int t;
Test() {
}
}
The program has pilation error because t is not initialized.
The piles, but has a runtime error because t has no initial value.
The program has pilation error because you attempt to create an object of the Test inside the Test class.
The piles and runs fine.
Analyze the following code:
class Test {
private int t;
public static void main(String[] args) {
Test test = new Test();
int x;
();
}
}
The variable t is not initialized and therefore causes errors.
The variable t is private and therefore cannot be accessed in the main method.
The variable x is not initialized and therefore causes errors.
The piles and runs fine.
Suppose s1 and s2 are two strings. Which of the following statements or expressions are incorrect?
String s = new String("new string");
String s3 = s1 + s2;
String s3 = (s2);
s1 >= s2
Suppose s1 and s2 are two strings. Which of the following statements or expressions are incorrect?
String s3 = s1 - s2;
int i = pareTo(s2);
char c = s1[0]; ??????????????????????
A and C
Which of the following statement is not true?
The contents of a string can be partially changed.
You can add, insert, or delete characters from a string buffer.
You can create a string buffer from a string. ???????????????????????
You can convert a string buffer i
java 来自淘豆网m.daumloan.com转载请标明出处.