SCJP certification package analysis

zhaozj2021-02-08  236

21, Which of the folowing assocignment is not correct?

A. float f = 11.1;

B. Double D = 5.3e12;

C. Double D = 3.14159;

D. Double D = 3.14d.

(a)

Title: Which assignment statements below are right.

The assignment of floating point is DUBLE type, if f or f is added after floating point numbers, then D or D is Double, the floating point number of scientific counting is also Double type And the Double's precision is higher than Float, and a high-precision Double assignment is required to enforce type conversion when a low-precision Float is required, and it is not necessary.

22, Given The Uncompleted Code of a class:

Class Person {

String name, department;

Int agec;

Public Person (String n) {name = n;

Public Person (String n, int a) {name = n; agent = a;

Public Person (String n, string d, int a) {

// doing the Same as Two Arguments Version of Constructor

// incruding assignment name = n, agn = a

Department = D;

}

}

Which Expression Can Be Added At The "Doing The Same As ..." Part of the constructor?

A. Person (N, A);

B. THIS (Person (N, A));

C. THIS (N, A);

D. THIS (Name, AGE).

(c)

Title: Give the incomplete class code below:

...

Which expressions below can be added to the "doing the Same as ..." in the construction method?

The other constructors of this class are called in different construction methods in the same class, and the form of this (...) is required, and must be in the first line of constructing, this and ordinary method overloaded the way, ordinary The method can be called directly to call, and the call position is not limited, so the answer A is not linear, the syntax of B is wrong, and the error is the member of the parent type constructor before being called member. . The constructor is a starting point of a class object instantiation (although the first statement that is not constructed, it is not the first statement of the constructor, but the allocation of the memory), and therefore the member cannot be referenced as a parameter in the constructor.

23, Which of The Following Statements About Variables and Their Scopes Are True?

A. Instance Variables Are Me Member Variables of a class.

B. Instance Variables Are Declared with The Static Keyword.

C. Local Variables Defined Inside a Method Are Created When the Method Is Executed.

D. Local Variables Must Be Initialized Before.

(ACD)

Title: What is the above for the following statements about variables and scope.

A. Example variable is a member variable of class.

B. Instance variables State with keywords. C. The local variable defined in the method is created when the method is executed.

D. Local variables must be initialized before use.

There are several variables in the class: local variables (English can be: local / automatic / temporary / stack variable) is the variable defined in the method; instance variable (English is: instance variable) is outside the method Declaring variables, sometimes called member variables; class variables (English: class variable) are instance variables declared with keyword Static, and their survival is: local variables are called when defining this variable. Create, and cancel it after this method; instance variable is created when using new xxxx () to create instances of this class, and its survival is the same as the living life of the instance object of the class; class variables are loaded in this class When you are created, don't be created with new xxxx (), all instance objects of all such classes share this type variable, and its survival is the survival of the class. Any variable must be initialized before use, but it is necessary to point out that the local variable must explicitly initialize, and the instance variable does not have to be, the original type of instance variable is allocated for the default value it allocates when the constructor of this class is called. The type is 0, the Boolean is false, and the floating point is 0.0F, the default value of the instance variable of the reference type (class type) is NULL (not actually initialization, the use of nullpointexception), class variables The rules and example variables are the same, and the difference is that the initialization of class variables is when the class is loaded.

24, public void test () {

Try {oneMethod ();

System.out.Println ("Condition 1");

} catch (arrayindexoutofboundsexception e) {

System.out.Println ("Condition 2");

} catch (exception e) {

System.out.Println ("Condition 3");

} finally {

System.out.println ("FINALLY");

}

}

Which Will Display if OneMetHod Run Normal?

A. Condition 1

B. Condition 2

C. Condition 3

D. Finally

(AD)

Title: What will I show when the oneMethod () method runs normally?

If the statement in the TRY block occurs during execution, execute the interrupt from the site, enter the CATCH block, match the abnormality, the most advanced priority matching comparison, as long as the exception is the unusual subclass specified in CATCH The content in the corresponding CATCH will be successfully performed, and the content in the Finally block will be executed regardless of whether an exception occurs.

25, Given The Following Code:

Public class test {

Void PrintValue (int M) {

Do {system.out.println ("The value is" m);

}

While (--M> 10)

}

Public static void main (string arg []) {

INT i = 10;

Test T = New Test ();

T.PrintValue (i);

}

}

Which Will Be Output? A. The value is 8

B. The Value IS 9

C. The value is 10

D. The value is 11

(c)

Title: Give the following code:

...

What will output?

This question is the knowledge of the Do ... while, do ... while is executed at least once, and after executing the content in the DO, it is true if the conditions in the While are True. If you are True, do DO The content, then make judgments, with this class to the While judgment to FALSE to exit the contents of the loop after the loop execution cycle, and the rule of the operator is on the right side of the variable - will be calculated first, and then make the variable The value is reduced, and on the left of the variable is to reduce the value of the variable again and again.

26, Which of the folloading statements About Declaration Are True?

A. Declaration of Primitive Types Such as boolean, byte and so on does not allocate memory space for the variable.

B. Declaration of Primitive Types Such as Boolean, byte and so on allocates memory space for the variable.

C. Declaration of Nonprimitive Types Such AS String, Vector and So on Does Not Allocate Memory Space for the Object.

D. Declaration of Nonprimitive Types Such As String, Vector Ans So on Allocates Memory Space for the Object.

(AD)

Title: What describes the following description below.

A. The declaration of the original data type such as Boolean, Byte's variable is not allocated memory space for the variable.

B. The declaration of the original data type such as Boolean, Byte variable will allocate memory space.

C. Non-raw data types such as String, the declaration of variables of the Vector will not allocate memory for the object.

D. Non-raw data types such as String, Vector's variable declaration assigns memory for the object.

Declaration of variables for raw data types will be allocated to the memory and give a default value, see the number of 23 questions, rather than the number of variables of the non-original data type must be allocated with the new xxxx () to allocate memory and initialization. However, strictly speaking the answer from this question is to be determined because only the original type of instance variable and class variable declaration completes the auto-allocation of the memory when the class object is created / class is loaded, and the local variable of the original type must be explicitly initialized. From this point of view, the local variable of the original type is not automatically allocated, and only the variable of non-raw data types in SL275 must use new xxxx () to complete memory allocation without pointed out whether the original data type variable is declared. Automatic memory allocation, and from local variables cannot be used to use this before explicit initialization, there is no memory allocation when declaring. Therefore, the correctness of the answer A is still to be determined by the official.

27, in The Java API Documentation Which Sections Are INCLUDED IN A CLASS DOCUMENT?

A. The description of the class and its purpose

B. A List of methods in its super class

C. a List of Member Variable

D. The Class Hierarchy

(ACD)

Title: Which parts of the Java API document are included in, I, Type A. Class and use description

B. List of methods for parent class

C. List of member variables

D. Class level

The content of class documents is mainly: class level, class and application description, member variable list, constructor list, member method list, method list inherited from class hierarchy, detailed description of member variables, constructor, detail, member method Description.

28, Given The Following Code:

1) public void modify () {

2) INT I, J, K;

3) i = 100;

4) While (i> 0) {

5) J = I * 2;

6) System.out.println ("The Value of J Is" J);

7) k = k 1;

8) I -;

9) }

10)}

Which Line Might Cause AN Error During CompiLation?

A. Line 4

B. Line 6

C. Line 7

D. Line 8

(c)

Title: Give the following code:

...

Which rows may generate errors when compiling.

This problem discussed in the problem of the previously related variables and its scope, local variables must be explicitly initialized before use, and the variable k in the code is not used.

29, Which of the folloading statements About variables and scope are TRUE?

A. Local Variables Defined Inside a Method Are Destroyed When the Method Is Exited.

B. Local Variables Are Also Called Automatic Variables.

C. Variables defined Outside a method is constructed.

D. A Method Parameter Variable Continues To EXIST for AS Long As The Object Is Needed in Which The Method Is Defined.

(ABC)

Title: The following is the above related variables and its scope.

A. The local variable defined in the method is revoked when the method exits.

B. Local variables are also called automatic variables.

C. The variables defined outside the method (the depolius: instance variable) are created when the object is constructed.

D. The parameter of the method defined in the method will always exist as long as the object is needed.

This question is still discussed the type of variable and the scope of the field, referring to the previous narrative.

30, a class design Requires That a Member Variable Cannot Be Accessible Directly Outside The Class. Which Modifier SHOULD BE Used To Obtain The Access Control?

A. Public

B. NO Modifier

C. protected

D. private

(d)

Title: Class design requires that a member variable of its member cannot be directly accessed by external classes. It should be used to obtain the required access control using the following modifiers.

This also narrative in front, Java has four access types, respectively: public, protected, default, private, where the public variable can be accessed by all external classes, while pretected can be accessed by the same package and the subclass of this class Default is not accessible by any modifier, and the private variable can only be accessed inside the class. The external classes in the topic should be understood as all other classes of such their own, so only using private can meet the requirements. 31given the following code fragment:

1) String str = null;

2) IF ((Str! = Null) && (str.length ()> 10)) {

3) System.out.println ("More Than 10");

4)}

5) ELSE IF ((Str! = Null) & (Str.Length () <5)) {

6) System.out.Println ("Less Than 5");

7)}

8) Else {system.out.println ("end");

Which Line Will Cause Error?

A. Line 1

B. Line 2

C. Line 5

D. Line 8

(c)

Title: Give the following code segment:

...

Which rows will result in errors.

This question needs to be cleared carefully. The query has no logic error. If ... Else is used, there is no problem, and there is no spelling error, and the error is the use of the 5th line "and" logical operator "" With "should be &&, and" Bitwise Logical Operator "" with ", the" with "of the logical operator should be the left and right operands of the Logical Boolan. Value, and the left and right operands of the bit logic operator are integral values.

32, Which Statements About Java Code Security Are True?

A. The Bytecode Verifier Loads All Classes Needed for the Execution of a Program.

B. EXECUTING CODE IS Performed by the runtime interpreter.

C. At Runtime The Bytecodes Are Loaded, Checked and Run in An Interpreter.

.

(BCD)

Title: What is the description of Java code security below.

A. Bytecode Checker loading the query executes all classes required.

B. Runtime interpreter execution code.

C. At runtime, bytecode is loaded and verified and then run in the interpreter.

D. The class loader adds security by separating the class of the native file system and the class imported from the network.

The process of running in the Java program described in SL275 is such that all classes required for class loader load program running, which can increase security by distinguishing between class and network systems imported by local file systems, this can Limit any Trojan horse, because the machine class is always loaded first, once all classes are loaded, the memory division of the execution file is fixed, at this time, the specific memory address is assigned to the corresponding symbol reference, lookup The table (Lookuo Table) is also established. Since the memory division occurs at runtime, the interpreter adds protection to prevent unauthorized access; then the Byte code Verifier checks, mainly Execute the following check: Class compliance with the JVM specification class file format, no violation of access restrictions, the code does not cause the stack or the overflow, all the parameter types of all operation code are correct, no illegal data type conversion (for example Integer number conversion to object types) occur; the bytecode of the verification is executed by the interpreter, and the interpreter performs appropriate calls to the underlying hardware by runtime system when necessary. The last three answers are the original words in SL275. 33, Given The Following Code:

Public class person {

Static int Arr [] = new int [10];

Public static void main (string a []) {

System.out.println (Arr [1];)

}

}

Which Statement Is Correct?

A. WHEN Compilation Some Error Will Occur.

B. IT IS CORRECT WHEN Compilation But Will Cause Error When Running.

C. The Output is Zero.

D. The Output is Null.

(c)

Title: Give the following code:

...

That narrative is right.

A. Errors will occur when compiling.

B. Error when compiling is correct but run.

C. Output is 0.

D. Output to null

The int type array is a class object, which is completed when the class is loaded, and it has been described in the previous topic. Since it is the original data type INT, its initial value is 0.

34, Given The Following Code:

Public class person {

Int arr [] = new int [10];

Public static void main (string a []) {

System.out.println (Arr [1]);

}

}

Which Statement Is Correct?

A. WHEN Compilation Some Error Will Occur.

B. IT IS CORRECT WHEN Compilation But Will Cause Error When Running.

C. The Output is Zero.

D. The Output is Null.

(a)

Give the following code:

...

Which describes are right.

A. Compile time error.

B. Error running correctly when compiling.

C. Output 0.

D. Output NULL.

The instance variable completes initialization when the class is constructed, and the non-static member of the class cannot be directly accessed in the static method of the class, which can only access the class member (like the topic as the topic), and the common method of the class can access all the classes. Members and methods, while static methods can only access static members and methods of classes, because static methods belong to class, and ordinary methods and member variables belong to instances of classes, class methods (static methods) cannot use a certain uncertain class The methods and variables of the examples, there is no implied THIS in the static method, and the ordinary approach has. 35, public class parent {

Public Int AddValue (int A, int b) {

Int S;

s = a b;

Return S;

}

}

Class Child Extends Parent {

}

Which Methods Can Be Added Into Class Child?

A. Int AddValue (int A, int b) {// do something ...}

B. Public void addvalue () {// do something ...}

C. Public int AddValue (int A) {// do something ...}

D. Public Int AddValue (int A, int b) throws myexception {// do something ...}

(BC)

Topic: What methods can be added to the class Child.

This title involves the method overload, Override and the rules rewritten when the class is derived. The rules of the method are: 1. The parameter list must be different, the number of different numbers can be different, if the number is the same, the parameter type cannot cause mismics, such as int and long, float and double can not be used as the unique type. Second, the return value can be different, but the only difference between the heavy load (this is different from C , the return type in C must be consistent). Method rewrite occurs when the class is inherited, the subclass can rewrite the existing methods in a parent class, must be rewritten when the return type and the parameter list, otherwise it is overloaded, one of Java is overwritten Important and easily ignored rules are access to the way to rewrite the way to access the accessibility than the rewritten method! Another rule of rewriting is that the method of rewriting cannot abandon more types of exceptions than the rewritten method, and the abandoned abnormality can only be less, or its subclass, not to abandon the number of abnormalities. Judgment the type, but should be the type of exception class level. The error of the answer A in this question is that the access permission to rewrite is lower than the rewritten method, and B, C belongs to the overload, and the error is to abandon more kinds of exceptions than the rewritten method.

36, A Member Variable Defined in a class can be accepted Only by the classes in The Same package. Which modifier shop be used to ketain the access control?

A. Private

B. NO Modifier

C. public

D. protected

(b)

Topic: The member variable defined in a class can only be accessed by class in the same package. Which modifications below can achieve the required access control.

See the narrative in the topic of the previous topic.

37, A Public Member Vairable Called Max_length Which Int Type, The Value of The Variable Remains Constant Value 100. Use a short statement to define the variable.a. Public int max_length = 100;

B. Final Int max_length = 100;

C. final public int max_length = 100;

D. Public Final Int Max_length = 100.

(d)

Title: A common member variable max_length is an INT type value, and the value of the variable maintains a constant value of 100. Use a short declaration to define this variable.

The common variables in Java use public definitions, constant variables use final, and pay attention to the order of the modifier, one of the most complete modifications is Public Static Final Int varial_a = 100; this order cannot be faulty, this is different from C . The answer C is just right in the order of modifiers.

38, Which Expressions Are Correct to Declare ARRAY OF 10 string Objects?

A. CHAR STR [];

B. CHAR STR [] [];

C. String Str [];

D. String Str [10];

(c)

Topic: Which expressions are declared an array containing 10 String objects.

Strictly, this topic has not given a correct answer, the only thing is C, and the requirements of the topic meet the requirements: string str [] = new string [10];

Note that the form of answers is wrong, this and C is also different.

39, Which Fragments Are Correct in Java Source File?

A. package testpackage;

Public class test {// do something ...}

B. Import java.io. *;

Package testpackage;

Public class test {// do something ...}

C. Import java.io. *;

Class Person {// do something ...}

Public class test {// do something ...}

D. Import java.io. *;

Import java.awt. *;

Public class test {// do something ...}

(ACD)

Title: The following Java source file code snippet is right.

The Package statement in Java must be a first statement other than the source file, and the import packet statement can be several, but after the Package statement, there must be several classes in one source file, but You can only have one as a public, if any, the file name of the source file must be the same as the class name of the class.

40:

String s = "hello";

String t = "hello";

CHAR C [] = {'h', 'e', ​​'l', 'L', 'o'};

Which returnes?

A. S.Equals (T);

B. T. Equals (C);

C. s == T;

D. T. Equals (New String ("Hello"); E. T == C.

(AD)

Title: What are you returning to true.

This is discussed in the discussion of the equals () method and == operator in the previous item 10. == The operator is compared to whether the operand number is the same object, and the String's equals () method is compared to whether the contents of the two String objects are the same, and the parameters are like a String object, it is possible to return TRUE Other objects return false.

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

New Post(0)