?? mockcert03.txt
字號(hào):
3) The compiler will object to the char literal in line 3.
Question 48
===========================================================
You are writing code for a class which will be in the default package and will use the graphic components in the AWT package. Select the correct code fragment to start the source code file.
Fragment A: import java.awt.*;
Fragment B: package default; import java.awt.*;
Fragment C: import java.awt.*; package default;
Mutiple:
1) Code Fragment A
2) Code Fragment B
3) Code Fragment C
Question 49
===========================================================
The following lists the complete contents of the file named Derived.java.
public class Base extends Object{
String objType;
public Base(){ objType="I am a Base type";}
}
public class Derived extends Base{
public Derived() { objType="I am a Derived type";}
public static void main(String args[]){
Derived D=new Derived();
}
}
What will happen when this file is compiled?
Mutiple:
1) Two class files, Base.class and Derived.class will be created.
2) The compiler will object to line one.
3) The compiler will object to line seven.
Question 50
===========================================================
Consider the following program:
public class Test {
public static void main (String args []){
boolean a = false;
if (a = true)
System.out.println("Hello");
Else
System.out.println("Goodbye");
}
}
What is the result:
Mutiple:
1) Program produces no output but terminates correctly.
2) Program does not terminate.
3) Prints out "Hello"
4) Prints out "Goodbye"
Question 51
===========================================================
Examine the following code which includes an inner class:
public final class Test4 implements A {
class Inner {
void test() {
if (Test4.this.flag); {
sample();
}
}
}
private boolean flag = false;
public void sample() {
System.out.println("Sample");
}
public Test4() {
(new Inner()).test();
}
public static void main(String args []) {
new Test4();
}
}
What is the result:
Only One:
1) Prints out "Sample"
2) Program produces no output but terminates correctly.
3) Program does not terminate.
4) The program will not compile
Question 52
===========================================================
Carefully examine the following class:
public class Test5{
public static void main (String args []){
/* This is the start of a comment
if (true) {
Test5 = new test5();
System.out.println("Done the test");
}
/* This is another comment */
System.out.println ("The end");
}
}
What is the result:
Mutiple:
1) Prints out "Done the test" and nothing else.
2) Program produces no output but terminates correctly.
3) Program does not terminate.
4) The program will not compile.
5) The program prints out "The end" and nothing else.
Question 53
===========================================================
The following code defines a simple applet:
import java.applet.Applet;
import java.awt.*;
public class Sample extends Applet {
private String text = "Hello World";
public void init() {
add(new Label(text));
}
public Sample (String string) {
text = string;
}
}
It is accessed form the following HTML page:
<html>
<title>Sample Applet</title>
<body>
<applet code="Sample.class" width=200 height=200></applet>
</body>
</html>
What is the result of compiling and running this applet:
Mutiple:
1) Prints "Hello World".
2) Generates a runtime error.
3) Does nothing.
4) Generates a compile time error.
Question 54
===========================================================
Examine the following code:
public class Calc {
public static void main (String args []) {
int total = 0;
for (int i = 0, j = 10; total > 30; ++i, --j) {
System.out.println(" i = " + i + " : j = " + j);
total += (i + j);
}
System.out.println("Total " + total);
}
}
Does this code:
Mutiple:
1) Produce a runtime error
2) Produce a compile time error
3) Print out "Total 0"
4) Generate the following as output:
i = 0 : j = 10
i = 1 : j = 9
i = 2 : j = 8
Total 30
Question 55
===========================================================
With which I/O operation can we append, update a file?
Mutiple:
1) RandomAccessFile()
2) Outputstream()
3) DataOutputstream()
Question 56
===========================================================
What does it mean when the handleEvent() returns the true boolean?
Mutiple:
1) the event will be handled by the componet.
2) the action() method will handle the event.
3) the event will be handled by the super.handleEvent()
4) do nothing
Question 57
===========================================================
Given is this class:
class Loop{
public static void main(String[] agrs){
int x=0;
int y=0;
outer:
for(x=0;x<100;x++){
middle:
for(y=0;y<100;y++){
System.out.println("x="+x+"; y="+y):
if(y==10){
<<<insert code>>>
}
}
}
} // main
} // class
The question is which code must replace the <<<insert code>>> to finish the outerloop?
Mutiple:
1) continue middle;
2) break outer;
3) break middle;
4) continue outer;
5) none of these
Question 58
===========================================================
What is the target variable in an Event?
Mutiple:
1) the Object() where the event came from
2) the Object() where the event is destined for
3) what the Object() that generated the event was doing.
Question 59
===========================================================
The following code resides in the source?
class StringTest{
public static void main(String[] args){
//
// String comparing
//
String a,b;
StringBuffer c,d;
c=new StringBuffer("Hello");
a=new String("Hello");
b=a;
d=c;
if( <<<operator>>> ) {}
}
} // class
Which of the following statement return true for the <<<operator>>> line in StringTest.class?
Mutiple:
1) b.equals(a)
2) b==a
3) d==c
4) d.equals(c)
Question 60
===========================================================
Which are valid identifiers?
Mutiple:
1) %fred
2) *fred
3) thisfred
4) 2fred
5) fred
Question 61
===========================================================
What will happen when you attempt to compile and run this code?
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();
}
}
Only One:
1) The code will compile and run, printing out the words "My Func"
2) The compiler will complain that the Base class has non abstract methods
3) The code will compile but complain at run time that the Base class has non abstract methods
4) The compiler will complain that the method myfunc in the base class has no body, nobody at all to looove it
Question 62
===========================================================
What will happen when you attempt to compile and run this code?
public class MyMain{
public static void main(String argv){
System.out.println("Hello cruel world");
}
}
Mutiple:
1) The compiler will complain that main is a reserved word and cannot be used for a class
2) The code will compile and when run will print out "Hello cruel world"
3) The code will compile but will complain at run time that no constructor is defined
4) The code will compile but will complain at run time that main is not correctly defined
Question 63
===========================================================
Which of the following are Java modifiers?
Mutiple:
1) public
2) private
3) friendly
4) transient
5) vagrant
Question 64
===========================================================
What will happen when you attempt to compile and run this code?
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();
}
}
Mutiple:
1) The code will compile and run, printing out the words "My Func"
2) The compiler will complain that the Base class is not declared as abstract.
3) The code will compile but complain at run time that the Base class has non abstract methods
4) The compiler will complain that the method myfunc in the base class has no body, nobody at all to looove it
Question 65
===========================================================
Why might you define a method as native?
Mutiple:
1) To get to access hardware that Java does not know about
2) To define a new data type such as an unsigned integer
3) To write optimised code for performance in a language such as C/C++
4) To overcome the limitation of the private scope of a method
Question 66
===========================================================
What will happen when you attempt to compile and run this code?
class Base{
public final void amethod(){
System.out.println("amethod");
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -