SCJP certification package analysis

zhaozj2021-02-08  207

41, Which of the folowing statements area legal?

A. long L = 4990;

B. INT i = 4L;

C. float f = 1.1;

D. Double D = 34.4;

E. Double T = 0.9f.

(ADE)

Title: Which statements below are legal.

The test point of this question is the type of representation of the numbers and the type of basic data type, and there is no number of decimal points is considered an int type. The number with decimal points is considered to be a double type number, and the other uses after the number is added. The letter represents the data type, plus L or L is a long type, plus D or D is Double, plus f or f is float, which can assign low-precision numbers to high-precision variables, and then need to make mandatory type conversion, for example INT, Short, BYTE assignment does not require explicit type conversion, in turn, it needs to force conversion when assigning the LONG type to Byte, Short, and INT type (int A = (int) 123L;).

42,

Public class pent {

Int change () {...}

}

Class Child Extends Parent {

}

Which Methods Can Be Added Into Class Child?

A. public int change () {}

B. Int Chang (INT i) {}

C. private int change () {}

D. Abstract int Chang () {}

(AB)

Title: Which methods can be added to CHILD.

The problem of this topic has a detailed description in the 35th question. It should be noted that the content of the answer d, the subclass can rewrite the method of the parent class and declare the abstract method, but this triggered problem is that the class must declare an abstract class, otherwise the compilation cannot pass, but the abstract method does not have a method The body, that is, the method statement cannot bring that two braces ({}), these D cannot be met.

43,

Class Parent {

String one, two;

Public Parent (String a, string b) {

One = a;

TWO = B;

}

Public void print () {system.out.println (one);}

}

Public class child extends pent {

Public Child (String A, String B) {

Super (a, b);

}

Public void print () {

System.out.println (One "To" TWO);

}

Public static void main (string arg []) {

PARENT P = New Parent ("South", "North");

Parent T = New Child ("EAST", "West");

p.Print ();

T.Print ();

}

}

Which of the folloading is correct?

A. Cause Error During CompiLation.

B. South

East

C. South to Northh

East To West

D. South to Northh

East

E. South

East To West

(e)

Title: What is correct below.

A. Error in compile.

This topic involves the problem of polymorphism in inheritance. It has already been described in the previous problem. It is important to note that the statement T.Print (); actually pointing at runtime That is a Child object, that is, Java determines variables at runtime. The actual type, and when T is a Parent object at compile time, so if there is no method in the parent class in the subclass Child, T.Printall () cannot be used. See the narrative of 12 questions. 44, a button is posiented in a frame. Only Height of the button is affected by the frame while the width is not. Which layout manager shop be used?

A. FlowLayout

B. CardLayout

C. North and South of BorderLayout

D. East and West of BorderLayout

E. GridLayout

(d)

Topic: A button is placed in a framework, only affects the height of the button during the framework, which is not affected, which layout manager should I use?

This or the problem of layout manager, flow layout manager (FlowLayout) will adjust the size of the components in its size, including height and width according to the size of the frame, including height and width, this manager does not constrain the size of the component, but allows them to get themselves. The best size, one line will be placed next to the next line; Cardlayout once explicitly an added component (based on the keyword to join); GridLayout divide the container into fixed Grid, change in container size will affect the size of all components, the size of each component will change the same place; BorderLayout divides the container into five areas, divided into northwest and middle, and the width of the east and west is The optimum width of the components in the region, the height of the container minus the height of the North and South area, which is a variable value, and the width of the North and South is the entire width of the container, the height is the best height of the component, the intermediate area The height is the height of the container minus the height of the north-south region, and the width is the width of the container minus the width of the things.

45, Given The Following Code:

1) Class Parent {

2) private string name;

3) public parent () {}

4)}

5) Public class child extends parent {

6) Private string department;

7) public child () {}

8) Public string getValue () {return name;}

9) Public static void main (string arg []) {

10) parent p = new parent ();

11)}

12)}

Which Line Will Cause Error?

A. Line 3

B. Line 6

C. Line 7

D. Line 8

E. Line 10

(d)

Title: Give the following code:

...

Which rows will result in errors.

Chapter 8 getValue () attempts to access the private variables of the parent class, error, refer to the narrative of the above-related variable type and its scope.

46, The Variable "Result" is Boolean. Which Expressions Are Legal? A. Result = true;

B. IF (result) {// do something ...}

C. IF (result! = 0) {// so sadhing ...}

D. Result = 1

(AB)

Title: Variable "Result" is a Boolean type value, which expressions below are legal.

Java's Boolean is different from the Boolean value in C or C , and the boolean value in Java is the Boolean value, and other types of values ​​cannot be treated as Boolean.

47, Class Teacher and Student Are Subclass of Class Person.

Person P;

Teacher T;

STUDENT S;

P, T And S Are All Non-Null.

IF (T) {s = (student) t;}

What is the result of this society?

A. IT Will Construct A Studient Object.

B. The Expression is Legal.

C. IT IS ILLEGAL AT Compilation.

D. IT IS LEGAL At Compilation But Possible Illegal At Runtime.

(c)

Title: Class TEACHER and Student are subclasses of Person

...

P, T and S are non-null values

...

What is the result of this statement?

A. A Student object will be constructed.

B. Expression legal.

C. Compile time illegal.

D. It may illegal at runtime when compiling.

The role of the InstanceOf operator is to determine if a variable is an object of the class pointed out by the right operand. Since the polymorphism of the Java language makes the variable of a parent class with an instance of a sub-class, in some cases Judging the variable is a type of object, and instanceof can be used at this time. When the left operating number is the instance of the class pointed out or the instance of the subclass is returned, if it is assigned to the instance of a sub-class to a parent class, the variable is used to determine whether the variable is subclass. An instance will also return true. The judgment of the IF statement in this question is no problem, but it will return true, but the rear type conversion is illegal, because T is a Teacher object, it cannot be forced to convert to a Student object, even if these two classes are common father. If it is converted to a Person object, it is not necessary to force conversion. This error can be found when compiling, so compiling cannot pass.

48, Given The Following Class:

PUBLIC CLASS SAMPLE {

Long Length;

Public Sample (long L) {Length = L;

Public static void main (string arg []) {

Sample S1, S2, S3;

S1 = New Sample (21L);

S2 = New Sample (21L);

S3 = S2;

Long m = 21L;

}

}

Which Expression Returns True?

A. S1 == S2;

B. S2 == S3;

C. m == S1;

D. S1.Equals (m).

(b)

Title: Give the following class:

...

Which expression returns True.

The characteristics of the Equals () method that have been described above have been described above, and the operand on both sides of the operator must be the same type (can be between the parent son class) to compile.

49, Given The Following Expression About List.

List L = New List (6, true);

Which Statements Are Ture?

A. The Visible Rows of The List is 6 Unless OtherWise Constrained.

B. The Maximum Number of Characters in a Line Will BE 6.

C. The List Allows Uses To Make Multiple Selects

D. The List Can Be Selected Only ONE ITEM.

(AC)

Title: Give the following to the expression of List:

...

Which describes are right.

A. The list will have 6 lines of visible under conditions without other constraints.

B. The maximum number of characters in a row is 6

C. The list will allow users to make multiple selections.

D. The list can only be selected.

The first parameter of the construction method of the List component is its initial explicit line number, and if the value is 0, the 4 line is displayed, and the second parameter is specified whether the component can be multi-selection, if the value is TRUE It is possible to select, if it is not specified, the default is unable to select.

50, Given The Following Code:

Class Person {

String name, department;

Public void printvalue () {

System.out.println ("Name IS" Name);

System.out.Println ("Department IS" Department;

}

}

Public class teacher extends person {

Int Salry;

Public void printvalue () {

// doing the same as in the parent method printvalue ()

// inclished Print The value of name and divaTment.

System.out.println ("Salary IS" SALARY;

}

}

Which Expression Can Be Added At The "Doing The Same As ..." Part of the method printvalue ()?

A. PrintValue ();

B. this.printValue ();

C. Person.printValue ();

D. super.printValue ().

(d)

Title: Give the following code:

...

Which expressions below can join the "Doing The Same as ..." section of the PrintValue () method.

Subclasses can rewrite the method of the parent class, in the corresponding method of the subclass, to call the rewritten method to call "Super." In front of the method, if the call is not rewritten Method, you don't need to add super. Call, and you can write directly. Here, it is to point out the recursive call of the Java support method, so the answers A and B have no errors in the grammatical, but do not meet the requirements of the inscription of the title code: that is, the same thing in the method of the parent class - print Names and departments, strictly, can also choose A and B.

51, WHICH IS NOT A METHOD of THE CLASS INPUTSTREAM? A. Int int

B. Void Flush ()

C. Void Close ()

D. int available ()

(b)

Title: Which of the following is not a method in the inputStream class

This topic is not good, requiring some basic classes in the Java API, the INPUTSTREAM in the topic is the parent class of all input streams, all are familiar, see the JDK's API document. Method Void flush () is the basic method of buffer output stream, which is forced to force the current content in the stream buffer to force the output.

52, Which Class Is Not Subclass of FilterInputStream?

A. DataInputStream

B. BUFFEREDInputStream

C. PushbackInputStream

D. FileInputStream

(d)

topic:

Which is not subclass of FilterInputStream.

This question is also asking for familiar with the API basic class. FilterInputStream known subclass of the Java basic API, are: BufferedInputStream, CheckedInputStream, CipherInputStream, DataInputStream, DigestInputStream, InflaterInputStream, LineNumberInputStream, ProgressMonitorInputStream, PushbackInputStream.

53, Which Classes Can BE Used as the argument of the constructor of the class fileinputstream?

A. InputStream

B. File

C. FileOutputStream

D. String

(BD)

Title: Which classes can be used as parameters of the construction method of the FileInputStream class.

This question is also required to be familiar with the foundation API, and the FileInputStream class has three, acceptable parameters are: File, FileDescriptor, a object of the String class.

54, Which Classes CAN BE Used as the argument of the constructor of the class filterinputstream?

A. FilterOutputStream

B. File

C. InputStream

D. RandomaccessFile

(c)

Title: Which classes can be used as a parameter of the construction method of the FilterInputStream class.

The FilterInputStream constructor is only one, and its parameters are an InputStream object.

55, Given The Following Code Fragment:

1) Switch (M)

2) {cas 0: system.out.println ("case 0");

3) Case 1: System.out.println ("Case 1"); Break;

4) Case 2:

5) Default: system.out.println ("default");

6)}

Which value of m would cause "default" to be the output?

A. 0

B. 1

C. 2

D. 3

(CD)

Title: Give the following code segment:

...

M is which values ​​will result in the "default" output.

This topic examines the usage of the Switch statement, the condition of Switch's judgment must be an INT value, or the value of Byte, Short, a CHAR type, and it is necessary to pay attention to the case, which is generally connected to a BREAK statement to end judgment. Otherwise, other Case will continue without any judgment. If no value is in line with the judgment of the case, execute the default statement, Default is optional, can not, if there is no default, no value matches Case The listed values ​​is displayed by Switch does not perform any statements. 56, Given the Uncompleted Method:

1)

2) {success = connect ();

3) IF (Success == - 1) {

4) throw new timedoutexception ();

5)}

6)}

Timedoutexception is not a runtimeException. Which CAN Complete THETHOD OF DECLATION WHEN ATED AT LINE 1?

A. Public void method ()

B. Public void method () THROWS EXCEPTION

C. Public void method () THROWS TIMEDOUTEXCEPTION

D. public void method () throw timedoutexception

E. Public throw timedoutexception void method ()

(BC)

Title: Give the following incomplete method:

...

Timedoutexception is not a RuntimeException. Which statements below can be added to the first line to complete the declaration of this method.

If the program throws an exception during the run, this exception is not RuntimeException or error, then the program must capture this exception to process or declare the abnormality, capture exceptions can use TRY {} catch () {} statement And abandoning anomalies in the method statement, declaration, in the following declarations, plus throws xxxxexception, abandon multiple exceptions, use commas (,), separated by each abnormality, the program is thrown at runtime, not a runtimeException, All must be captured or abandoned, and the procedure is not captured, all should declare the abandonment in the method statement. Since Exception is all unusual parent classes, all of course can also represent runtimeException.

57, Which of the folowing answers IS CORRECT TO EXPRESS THE VALUE 10 IN HEXADECIMAL NUMBER?

A. 0xA

B. 0x16

C. 0A

D. 016

(a)

Title: Which answers below can correctly represent a hexadecimal number 10.

The number of hexadecimal is starting with 0x, with 0 out of the eight-input number. The A, B, C, D, E, and F in the hexadecimal representation are 10, 11, 12, 13, 14, 15.

58, Which Statements About Thread Aread? True?

A. Once a thread is created, IT CAN Star Running Immediately.

B. To Use the start () Method Makes A Thread Runnable, But it Does Not Necessarily Start Immediately.

C. WHEN A THREAD Stops Running Because of Pre-Emptive, IT IS Placed At The Front End of The Runnable Queueue.d. A Thread May Cease to Be Ready for a Variety of Reasons.

(BD)

Title: What describes what the thread is right.

A. Once a thread is created, it starts running immediately.

B. Use the start () method to make a thread become operational, but it does not necessarily start running immediately.

C. When a thread stops running the first mechanism, it is placed in front of the run queue.

D. A thread may stop because of different reasons and enter ready state.

A newly created thread is not automatically started. It must call its start () method to put the thread into the runnable state, which means that the thread can be scheduled for the JVM thread scheduler. It doesn't mean it can run immediately. The scheduling of the thread is a predecessor, rather than a time slice. With threads that are higher than the current running thread, the current thread is stopped to enter and enter the ready state. The threads between the different priorities are pre-patterned, while the same thread is rotation. A thread stop can be because of different reasons, it may be because of the preemption of higher priority threads, it may also be because of calling the Sleep () method, even because the first stop does not necessarily enter the front of the run queue, because The same thread is a rotation, its operation may be because of the rotation, and it can only queue in the rotation queue until it is stopped by the preemption.

59. THE METHOD RESUME () Is Responsible for Resuming Which THREAD'S EXECUTION?

A. The Thread Which is Stopped by CallingMethod Stop ()

B. THREAD which is stopped by calling method sleep ()

C. The Thread Which is stopped by calling method Wait ()

D. The Thread Which is Stopped by Calling Method Suspend ()

(d)

Title: Method Resume () is responsible for restoring which threads are executed.

A. Threads stopped by calling the STOP () method.

B. Stop the running thread by calling the Sleep () method.

C. Stop the running thread by calling the wait () method.

D. Stop running threads by calling the supend () method.

The instructions in Thread's API document are that this method restores the suspended thread. The method first calls the CHECKACCESS () method of the thread, which may throw the securityException exception on the current thread, if the thread is alive but is suspended, it is restored and continues Execute the process.

60, Given The Following Code:

1) Public class test {

2) INT M, N;

3) Public test () {}

4) Public test (int A) {m = a;

5) Public static void main (string arg []) {

6) TEST T1, T2;

7) INT J, K;

8) j = 0; k = 0;

9) T1 = new test ();

10) T2 = new test (j, k); 11)}

12)}

Which Line Would Cause ONE ERROR DURING COMPILATION?

A. Line 3

B. Line 5

C. Line 6

D. Line 10

(d)

Title: Give the following code:

...

Which row will result in an error when compile.

The declaration of the 10th line calls a construction method of TEST with two parameters, and this class does not have such a constructor.

转载请注明原文地址:https://www.9cbs.com/read-1933.html

New Post(0)