81,094
社区成员
发帖
与我相关
我的任务
分享
(Java Script, Java,Java EE, Database Design, SQLQuery, MVC)
Circle one or more options which are correct.
1. Why would someone want to use JavaScript on a Web page? (5 scores)
A. To react to events that occur with Web page use
B. To read and write HTML
C. To validate data in a Web form
D. To pass data to a Java applet program
E. To run a clock or timer in a Web page
ACE C
2. Evaluate the following String method uses by writing the value of s after the evaluation (5 scores)
(write one value on the line to the right of each evaluation)
var str="Mix and Match"
A. s = str.indexOf("x")
B. s = str.indexOf("g")
C. s = str.indexOf("M")
D. s = str.lastIndexOf("a")
E. s = str.indexOf("and")
3. How can someone properly open a second Web browser window with a JavaScript statement?(5 scores)
A. document.openWin("http://www.thedomain.com/")
B. openWindow("http://www.thedomain.com/")
C. window.open(“http://www.thedomain.com/”)
D. document.open("http://www.thedomain.com/")
E. document.location("http://www.thedomain.com/")
4. Given the following valid HTML form, how would you assign the value typed into the owner
control to a variable ssn in a JavaScript statement?(5 scores)
<FORM Name=SSN Action=processme.html>
<INPUT Name=owner>
</FORM>
A. ssn = window.SSN.owner.value;
B. ssn = document.SSN.owner.value;
C. ssn = document.SSN.input.value;
D. ssn = document.form.input.value;
E. ssn = window.owner.value;
5. After a JavaScript function runs the following two lines of code, what value does the variable x contain?(5 scores)
arr = new Array(5);
x = Math.random() / arr.length;
A. a floating point number between 0.0 and 0.2
B. a floating point number between 0.0 and 0.25
C. a floating point number between 0.0 and 1.0
D. a floating point number between 0.0 and 5.0
E. x would not be assigned due to one or more errors in the code
6. What is the value of variable x after the following block of JavaScript code is run? (5 scores)
x=0;
y=2;
while(y>0.5 || y<0.0) {
x = x+1;
y = y/x - y;
}
A. 0
B. 1
C. more than 1
D. undetermined since the code divides by zero
E. less than 1
7. What will happen when you attempt to compile and run this code? (5 scores)
abstract class Base{
abstract public void myfunc();
public void another(){
System.out.println("Another method");
}
}
public class Abs extends Base{
public static void main(String argv[]){
Abs a = new Abs();
a.amethod();
}
public void myfunc(){
System.out.println("My Func");
}
public void amethod(){
myfunc();
}
}
A The code will compile and run, printing out the words "My Func"
B The compiler will complain that the Base class has non abstract methods
C The code will compile but complain at run time that the Base class has non abstract methods
D The compiler will complain that the method myfunc in the base class has no body, nobody at all to looove it
8. Which most closely matches a description of a Java Map? (5 scores)
A. A vector of arrays for a 2D geographic representation
B. A class for containing unique array elements
C. A class for containing unique vector elements
D. An interface that ensures that implementing classes cannot contain duplicate keys
9. What will happen when you attempt to compile and run the following code? (5 scores)
public class StrEq{
public static void main(String argv[]){
StrEq s = new StrEq();
}
private StrEq(){
String s = "Marcus";
String s2 = new String("Marcus");
if(s == s2){
System.out.println("we have a match");
}else{
System.out.println("Not equal");
}
}
}
A. Compile time error caused by private constructor
B. Output of "we have a match"
C. Output of "Not equal"
D. Compile time error by attempting to compare strings using ==
10. What will happen when you attempt to compile and run the following code? (5 scores)
import java.io.*;
class Base{
public void amethod()throws FileNotFoundException{}
}
public class ExcepDemo extends Base{
public static void main(String argv[]){
ExcepDemo e = new ExcepDemo();
}
public void amethod(){}
protected ExcepDemo(){
try{
DataInputStream din = new DataInputStream(System.in);
System.out.println("Pausing");
din.readByte();
System.out.println("Continuing");
this.amethod();
}catch(IOException ioe) {
}
}
}
A. Compile time error caused by protected constructor
B. Compile time error caused by amethod not declaring Exception
C. Runtime error caused by amethod not declaring Exception
D. Compile and run with output of "Pausing" and "Continuing" after a key is hit
11. What will happen when you attempt to compile and run this program? (5 scores)
public class Outer{
public String name = "Outer";
public static void main(String argv[]){
Inner i = new Inner();
i.showName();
}//End of main
private class Inner{
String name =new String("Inner");
void showName(){
System.out.println(name);
}
}//End of Inner class
}
A. Compile and run with output of "Outer"
B. Compile and run with output of "Inner"
C. Compile time error because Inner is declared as private
D. Compile time error because of the line creating the instance of Inner
12. What will be output by the following line? (5 scores)
System.out.println(Math.floor(-2.1));
A. -2
B. 2.0
C. -3
D. -3.0
13. What will happen when you attempt to compile and run the following code? (5 scores)
int Output=10;
boolean b1 = false;
if((b1==true) && ((Output+=10)==20)){
System.out.println("We are equal "+Output);
}else {
System.out.println("Not equal! "+Output);
}
A. Compile error, attempting to peform binary comparison on logical data type
B. Compilation and output of "We are equal 10"
C. Compilation and output of "Not equal! 20"
D. Compilation and output of "Not equal! 10"
14. Given the following variables
char c = 'c';
int i = 10;
double d = 10;
long l = 1;
String s = "Hello";
Which of the following will compile without error? (5 scores)
A.c=c+i; 不能把int类型转换成char
B.s+=i;
C.i+=s; 不能把String类型转换成int
D.c+=s; 不能把String类型转换成char
15. Given the following class definition, which of the following statements would be legal after the comment //Here? (5 scores)
class InOut{
String s= new String("Between");
public void amethod(final int iArgs){
int iam;
class Bicycle{
public void sayHello(){
//Here
}
}//End of bicycle class
}//End of amethod
public void another(){
int iOther;
}
}
A. System.out.println(s);
B. System.out.println(iOther);
C. System.out.println(iam);
D. System.out.println(iArgs);