⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mockcert04.txt

📁 一道JAVA方面的试题 很不错的 我很喜欢
💻 TXT
📖 第 1 页 / 共 5 页
字号:

Mutiple: 
1) drawOval(int x, int y, int width, int height)
2) toString()
3) drawArc(int x, int y, int width, int height, int startAngle, int arcAngle)
4) drawPolygon(int[] xPoints, int[] yPoints, int nPoints)
5) fillArc(int x, int y, int width, int height, int startAngle, int arcAngle)


Question 42
===========================================================
Which of the following are valid methods in the Math class?

Mutiple: 
1) arcTan(double a)
2) atan(double a)
3) sqrt(double a)
4) min(int a, int b)
5) cosine(double a)


Question 43
===========================================================
Which of the following will display the string "ica", given:      


     String s = "Metallica";

Mutiple: 
1) System.out.println(s.subString(7));
2) System.out.println(s.substring(6));
3) System.out.println(s.subString(6, 8));
4) System.out.println(s.substring(7, 9));
5) None of these.


Question 44
===========================================================
Which of the following are defined in the Object class?

Mutiple: 
1) toString()
2) equals(Object o)
3) public static void main(String [] args)
4) System.out.println()
5) wait()


Question 45
===========================================================
Select all valid statements relating to the paint() method defined in the Component class.

Mutiple: 
1) It takes 4 int types as parameters, representing the x and y co-ordinates, width and height, respectively.
2) It is declared as final, and so it cannot be overridden.
3) It is declared as static.
4) It takes an instance of the Graphics component as a parameter.
5) When overriding the paint() method, you must handle the identification and repair of damaged components.


Question 46
===========================================================
Which of the following keywords can be applied to a method?

Mutiple: 
1) transient
2) volatile
3) private
4) protected
5) final


Question 47
===========================================================
Which of the following keywords can be applied to a top-level class (i.e., not an inner class)?

Mutiple: 
1) private
2) protected
3) transient
4) public
5) final


Question 48
===========================================================
Consider the following piece of code, and select all relevant statements:


1. class Test{

2.     public static void main(String [] args){

3.         aMethod();

4.     }

5.

6.     static void aMethod(){

7.         try{

8.             System.out.println("abcd");

9.             return;

10.        } finally {

11.            System.out.println("1234");

12.        }

13.    }

14.}

Only One: 
1) An exception is thrown at line 9.
2) The code fails to compile. The compiler complains about the return statement at line 9.
3) abcd
1234
4) abcd
5) The code fails to compile, complaining that a 'catch' clause is missing from line 10.


Question 49
===========================================================
Which of the following statements are true.

Mutiple: 
1) The type "int" is a 32-bit signed integer value.
2) The type "short" is a 16-bit unsigned integer value.
3) The type "char" is a 16-bit Unicode character.
4) The type "float" is a 64-bit floating point value.
5) The type "long" is a 64-bit signed integer value.


Question 50
===========================================================
Which layout manager is described by the following:


It aligns components vertically and horizontally, without requiring that the components be of the same size. It maintains a dynamic rectangular grid of cells, with each component occupying one or more cells, called its display area.

Mutiple: 
1) GridLayout
2) FlowLayout
3) GridBagLayout
4) BoxLayout


Question 51
===========================================================
True of False.


The StringBuffer class overrides the toString() method to return a String representation of the StringBuffer.

Only One: 
1) True
2) False


Question 52
===========================================================
Select the correct statements from the following:

Mutiple: 
1) The class RandomAccessFile is a subclass of the java.io.File class.
2) The class java.io.FileWriter contains methods to write primitives (eg, writeInt(), writeFloat(), etc)
3) The class java.io.BufferedOutputStream contains methods to write primitives (eg, writeInt(), writeFloat(), etc)
4) The File class defines a method which can be used to delete files and directories from a disk.
5) The RandomAccessFile class defines a method which can be used to delete files and directories from a disk.


Question 53
===========================================================
True or False.


A class can implement more than one interface, but can only inherit from a single parent class.

Only One: 
1) True
2) False


Question 54
===========================================================
What is the result of compiling and executing the following code.


public class ThreadTest extends Thread {

     public void run() {

         System.out.println("In run");

         yield();

         System.out.println("Leaving run");

     }


     public static void main(String args []) {

         (new ThreadTest()).start();

     }

}

Mutiple: 
1) The code fails to compile in the main() method.
2) The code fails to compile in the run() method.
3) Only the text "In run" will be displayed.
4) The text "In run" followed by "Leaving run" will be displayed.
5) The code compiles correctly, but nothing is displayed.


Question 55
===========================================================
Which of the following will compile without errors.

Mutiple: 
1) Byte b = new Byte(123);
2) Byte b = new Byte("123");
3) Byte b = new Byte(); 
b = 123;
4) Byte b = new Byte((int)123.4);
5) Byte b = new Byte(0x123);


Question 56
===========================================================
Consider the following piece of code and select the correct statement(s):


1. public class Test{

2.     static int x;

3.     public static void main(String [] args){

4.         x = x + 1;

5.         System.out.println("Value is " + x);

6.     }

7. }

Only One: 
1) The code fails to compile. The compiler complains that the variable x is used before it is initialised.
2) The code compiles correctly and displays "Value is 1" when executed.
3) The code compiles correctly, but throws a NullPointerException at line 5.
4) The code fails to compile because the 'main' method is incorrectly declared.


Question 57
===========================================================
Which of the following are termed "short circuit" logical operators.

Mutiple: 
1) &
2) &&
3) |
4) ||
5) ^


Question 58
===========================================================
Which of the following are valid expressions.

Mutiple: 
1) Object o = new String("abcd");
2) Boolean b = true;
3) Panel p = new Frame();
4) Applet a = new Panel()
5) Panel p = new Applet()


Question 59
===========================================================
Which of the following is a valid way to declare an abstract method which is intended to be public.

Mutiple: 
1) public abstract method();
2) public abstract void method();
3) public abstract void method(){}
4) public virtual void method();
5) public void method() implements abstract;


Question 60
===========================================================
Which of the following are valid ways to define a constructor for class Test.

Mutiple: 
1) public void Test(){}
2) public Test(){}
3) private Test(){}
4) public static Test(){}
5) final Test(){}


Question 61
===========================================================
Which of the following statements are valid for a method which is overriding the following:


protected void method(int x){..}

Mutiple: 
1) The overriding method must take an int as its only parameter.
2) The overrding method must return a void.
3) The overriding method can be declared as private.
4) The overriding method can return any value it wishes.


Question 62
===========================================================
True or False.


An inner class can implement an interface or extend a class.

Only One: 
1) True
2) False


Question 63
===========================================================
Which of the following are valid return types for listener methods.

Only One: 
1) boolean
2) void
3) An object of type Event
4) An object of type Object
5) A long value, representing the Object ID.


Question 64
===========================================================
Consider the following piece of code and select the correct statements.


1.  public class Test{

2.      public static void main(String [] args){

3.          print();

4.      }

5.

6.      public static void print(){

7.         System.out.println("Test");

8.      }

9.

10.     public void print(){

11.         System.out.println("Another Test");

12      }

13. }

Mutiple: 
1) The code compiles successfully and displays "Test".
2) Changing the code at line 10 to the following, will allow the code to compile correctly:
3) The code fails to compile. The compiler complains about a static reference to a non-static method, print().
4) The code fails to compile. The compiler complains about duplicate methods.
5) Changing the return type on line 10 from 'void' to 'int' will allow the code to compile correctly.


Question 65
===========================================================
Consider the following list of tags and attributes of tags and select the ones which can legally be placed between the <applet> and </applet> delimiters.

Mutiple: 
1) JAVAC
2) JAR
3) CODE
4) NAME
5) PARAM


Question 66
===========================================================
Which variables can an inner class access from the class which encapsulates it.

Mutiple: 
1) All static variables
2) All final variables
3) All instance variables
4) Only final instance variables
5) Only final static variables


Question 67
===========================================================
Using a FlowLayout manager, which of the following is the correct way to add a conponent referenced by the variable "c" to a container:

Mutiple: 
1) add(c);
2) add("Center", c);
3) c.add();
4) c.set();
5) set(c);


Question 68
===========================================================
Assuming there is a class X which implements the ActionListener interface.


Which method should be used to register this with a Button?

Mutiple: 
1) addListener(new X());
2) addActionListener(new X());
3) addButtonListener(new X());
4) addActionAdapter(new X());
5) (new X()).addActionListener();


Question 69
===========================================================
What is the result of compiling and executing the following fragment of code:


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -