Java pen Question set (i)--javase part

Source: Internet
Author: User

Red answer for reference answer

1 , Select the correct one from the following options Java expression (multiple selection)

A. int k=new String ("AA"); B. String str=string ("BB");

C. Char c=74; D. Long j=8888;

2. The following functions are public void method () {...} the overloaded function ?

A public void method (int m) {...} B public int method () {...}

C public void Method2 () {...} D public int method (int m,float f) {...}

3. Which demonstrate a "has a" relationship (Choose)?

A. Public interface Person {}

public class Employee extends person{}

B. Public interface Shape {}

Public interface Rectandle extends Shape {}

C. Public interface Colorable {}

public class Shape implements colorable {}

D. public class species{}

Public class animal{private species species;}

E. Interface component{}

Class Container implements component{

Private component[] children;

}

Parsing: "Is-a" represents the inheritance between classes or classes and interfaces , such as cats are animals, dogs are animals, both inherit the common characteristics of animals, and then in OO language, should be defined as two species of cats and dogs, all inherit animal class. "Has-a" represents the affiliation of the object and his members , the same kind of object, which is distinguished by the different values of their properties.

4 . The known expression int m [] = {0,1,2,3,4,5,6}; which of the following expressions has the same value as the array subscript?

A m.length () B m. Length C m.length () +1 D m.length-1

5. method Resume () is responsible for recovering which threads are executed

A thread that is stopped by calling the Stop () method. B a thread that is stopped by calling the sleep () method.

C the thread that is stopped by calling the Wait () method. D The thread that was stopped by calling the Suspend () method.

6, please see the following code
Class Person {

private int A;

public int change (int m) {

return m;

}

}

public class Teacher extends person {

public int b;

public static void Main (String arg[]) {

Person p = new person ();

Teacher t = new Teacher ();

int i;

Point x

}

}
7 . Which of the following are placed on//point x? line is correct?
A i = m; b i = b;

C i = P.A; D i = p.change (+);

E i = t.b;

8, about operators >> and >>> description is correct

A. >> Perform move B. >> Perform rollover

C. >> Execute signed right shift>>> perform unsigned right shift D. >> Perform unsigned rightshift>> > performing a signed right shift

9 . The following description of the stack is correct

A stack is a non- linear structure b stack is a tree-like structure

C stack with FIFO feature D stack with LIFO feature

10. Select keywords in the Java language (multiple selection)

A. NULL B.  sizeof C.  Implements D. Extends

11, character (char) The integer representation range is

    1. 0 ...  32767 C. -256 ... 255
    2. 0 ...  65535 D. -32768 ... 32767

12, The following code execution results are

Class Super {
public int GetLength () {return 4;}

}

public class Sub extends Super {
Public long GetLength () {return 5;}

public static void Main (String[]args) {
Super Sooper = new super ();
Super Sub = new sub ();
System.out.println (Sooper.getlength () + "," + sub.getlength ());

}

}

A. 4, 4 B.  4, 5 C.  5, 4 D. 5, 5 E. Code cannot be compiled

13. about the Java Language, the following description is correct (multiple selection)

A. Switch cannot function on String type B. List, Set, Map all inherit from collection interface

C. The Java language supports goto statement D. GC is a garbage collector and programmers don't have to worry about memory management

, indicate the results of the following programs running

public class example{
  String Str=new string ("good");
  Char[]ch={' A ', ' B ', ' C '};
  public static void Main (String args[]) {
    Example ex=new Example ();
    Ex.change (ex.str,ex.ch);

Ex.str;
    System.out.print (ex.str+ "and");
    System.out.print (ex.ch);
  }
  public void Change (String Str,char ch[]) {
    str= "Test OK";
    Ch[0]= ' G ';
  }
}

A Good and ABC B good and GBC C test OK and ABC D test OK and GBC

15, write the following code execution result reference

public class MyClass {

static void Amethod (StringBuffer sf1, StringBuffer sf2) {

Sf1.append (SF2);

SF2 = SF1;

}

public static void Main (string[] args) {

StringBuffer SF1 = new StringBuffer ("A");

StringBuffer sf2 = new StringBuffer ("B");

Amethod (SF1,SF2);

System.out. println (sf1+ "": "+SF2);

}

}

Answer: Ab:b

16. About Anomalies (Exception) , the following description is correct (multiple selection)

A. The base class for the exception is Exception, and all exceptions must inherit it directly or indirectly .

B. exceptions can be used try{...} catch (Exception e) {...} to capture and process

C. If an exception inherits RuntimeException, the exception can not be declared

D. exceptions can be handled casually, rather than thrown to the outer layer of the program

17, ( radio " Declaring a delegate public int Mycallback ( int x); The prototype of the callback method produced by the delegate should be
A. void mycallback (int x)         b. int Receive (int num)
C. String receive (int x)             d. indeterminate

18, ( radio " The following code implements what mode in design mode
Span style= "font-family: Arial" > public class A {
private A instance;
private A () {
}
public static A getinstance {
if (A = = null)
 instance = new A ();
return instance;
}
 }
 a. Factory   b. Abstract Factory   c. singleton  D. Builder

19, three kinds of string method to sentence empty strings:
1:bool isEmpty = (str. Length = = 0);
   2:bool IsEmpty = (str = = String.Empty);
   3:bool IsEmpty = (str = = "");
which method is correct ?
A. 1 B. 2 c. 3

20, the following is correct

A) Float f = 3.14;   No f default is double type B) byte i = 225; The default is int type

C) Log k = 33; D) int p[[];

20 A day!! fighting!!

Java pen Question set (i)--javase part

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.