Can somebody help with their answers
Qustion 1.
String readString() {
char buf[] = new char[80];
Reader in = new InputStreamReader(System.in);
in.read(buf, 0, 80);
return new String(buf);
}
What is wrong with method readString()?
Choice 1
you can not cast InputStreamReader into Reader
Choice 2
all IO methods must be declared public
Choice 3
logic to catch exceptions for the InputStream statements is missing
Choice 4
an InputStreamReader object can not be bound to standard input
Choice 5
String objects can not be instantiated with a character array
Question 2.
Can an
applet "test" the system to determine its access rights? Why, or why not?
Choice 1
no, applets can not query the SecurityManager directly
Choice 2
yes, by attempting various operations and catching SecurityException's
Choice 3
no, the information is in the System object, which is restricted from applets
Choice 4
yes, by querying its ClassLoader object
Choice 5
no, the applet is automatically terminated when
Question 3
public int m1(int x) {
int count=1;
try {
count += x;
count += m2(count);
count++;
}
catch(ArithmeticException e) { count -= x; }
finally { count += 3; }
count++;
return count;
}
When m1(2) is invoked, m2() returns a value of 2 and m1() returns ________.
Choice 1
5
Choice 2
6
Choice 3
7
Choice 4
10
Choice 5
nothing. The system exits