SCJP certification question analysis
Author: Cherami
Email: cherami@163.net
The purpose of writing this article is to sum up ourselves to learn Java's knowledge points, and it can be convenient for others to learn Java. Personally feel that Java is really a good programming language, and learning Java must first master Java characteristics, and these features The SCJP can be fully reflected that the knowledge points of the question assessment are very in place, and Java must be well understood.
If there is a mistake in the text, welcome to correct! If you have any questions related to this article, please contact us. Thank you.
Welcome: http://www.smiling.com.cn/search/groupinfo.ecgi? Group_id = 23141 View my other works, the file sharing area contains the original of my all works.
Welcome, please keep the above information.
1, Which of the folloading range of short is correct?
-27 - 27-1
0 - 216-1
-215 - 215-1
-231 - 231-1
(c)
Title: Which of the following is the range of SHORT type.
The length of the short integer data type is 16 bits, with symbols. It is also necessary to explain that all integral numbers in Java (including Byte, Short, Int, long) are all symbolic.
2, Which Declarations of Identifiers Are Legal?
A. $ PERSONS
B. TWOUSERS
C. * Point
D. THIS
E. _endline
(a, b, e)
Title: Which of the following is a legal identifier.
The Java identifier can start with a Unicode character, a downlink (_), the US dollar ($), follow-up characters can be the symbols and numbers in front, no length limit, sensitive, can not be reserved.
3, Which Statement of Assigning a long Type Variable to a hexadecimal value is about?
A. Long Number = 345L;
B. Long Number = 0345;
C. long Number = 0345L;
D. long Number = 0x345L.
(d)
Topic: What is assiable a hexadecimal value to a long type variable.
The hexadecimal number starts with 0x, and the LONG model is in L (large-lowercase, usually using uppercase, because lowercase L and Number 1 are not easy to distinguish).
4. Which of the folloading fragments might cause errors?
A. String s = "gone with the wind";
String t = "good";
String K = S T;
B. String s = "gone with the wind";
String T;
T = s [3] "one";
C. String s = "gone with the wind";
String standard = S.touppercase ();
D. String s = "home directory";
String T = S - "Directory".
(b, d)
Title: Which of the following programs can cause errors. A: String Type You can use to connect to the connection.
B: String is an Object, rather than a simple character array, cannot use the subscript operation to take an element of its value, error.
C: Touppercase () method is a method of String object, and the role is to convert all the contents of the string to uppercase and return the conversion result (String type).
D: String type cannot be subtracted (-) operation, error.
5, 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
}
}
Which Are SyntActically Valid Statement AT / / POINT X?
A. i = m;
B. i = B;
C. i = p.a;
D. i = p.change (30);
E. i = T.b.
(d, e)
Title: Which of the Point X is legal in the sentence.
A: m is not exposed, can't be used.
B: Although B is a Public member variable of TEACHER, the non-stative member in the class cannot be used in the static method.
C: a is a private member of class Person, which cannot be directly referenced outside of the class.
D: Change (int M) method is a public method and returns an INT value that can be referenced and assigned to an INT variable by an instance variable P in the class.
E: B is the PUBLIC member variable of class Teacher, and it is an INT type, which can be referenced and assigned to an INT variable by the instance variable T of the class.
6, Which Layout Manager IS USED WHEN THE FRAME IS RESIZED THE button Might Be change?
A. BorderLayout
B. FlowLayout
C. Cardlayout
D. GridLayout
(b)
Title: Which of the layout managers in the Frame may be changed when the size of the frame is changed.
A: The layout manager divides the container into five parts, and the change in the size of the container does not affect the position of the components in which it affects their size.
B: This layout manager adjusts the position of the component according to the component of the component in which the component is placed, and the line cannot be accommodated, and the size of the container may change the position of the component.
C: The layout manager displays the components in the current page of the container, once displayed once, and the change in the size of the container cannot affect the position of the component.
D: The layout manager divides the container into fixed grid. After the component is added, the relative position of each component does not change because the container changes, and the change is only the size of the component.
7, Given The Following Code Fragment:
1) public void create () {
2) Vector myvect;
3) Myvect = new vector ();
4)} Which of the folloading statements are TRUE?
A. The Decaration on Line 2 Does Not Allocate Memory Space for the Variable MyVect.
B. The Declaration on Line 2 Allocates Memory Space for a Reference to a Vector Object.
C. The Statement Online 2 Creates An Object of Class Vector.
D. The Statement Online 3 Creates An Object of Class Vector.
E. The Statement Online 3 Allocates Memory Space for An Object of Class Vector
(ADE)
Title: Give the following code snippet. . . Which statements are TRUE (true)?
A. The declaration of the second line will not allocate memory space for variable myvect.
B. The second line declares allocates a memory space to the reference to the Vector object.
C. Create a VECTOR class object.
D. The third line statement creates a VECTOR class object.
E. The third line statement assigns memory space for a VECTOR class object.
The SL-275 pointed out: To assign space for a new object, you must execute new xxx () calls, and the new call is noted:
1. Assign space for the new object and initialize its members to 0 or NULL.
2. Perform initialization in the specifier. (For example, there is a member declared INT A = 10; at the first step, A = 0, execution to a second step A = 10)
3. Perform constructor.
4. Variables are assigned to a reference to new objects in memory stacks.
8. Which of the folloading answers?
A. 010
B. 0x10
C. 08
D. 0x8
(a)
Title: Which answers below can be used to represent an octave value 8.
The eight-input value starts with 0, with a hexadecimal value starting at 0x, and digital 8 is not available in octal 8, and only 7 is only 7.
9, Which Are Not Java Keywords?
A. True
B. Sizeof
C. Const
D. Super
E. Void
(AB)
Topic: What are not Java keywords.
A: Not, there is TRUE in Java, but this is not a keyword but a literal.
B: Not, this operator is not required in Java, all types (original type) size are fixed.
C, D, E are all, need to be explained, const is a keyword that is not used in Java.
10, Which of the folloading statements are TRUE?
A. The equals () Method Determines if Reference Values Refer to the Same Object.
B. The == Operator Determines if The Contents and Type of Tw Separate Objects Match.
C. The Equals () Method Returns True Only When The Contents of Two Objects Match.
D. The class file overrides Equals () TO RETURN TRUE IF The Contents and Type of Two Separate Objects Match. (AD)
Title: What describes the following description.
A. Equals () method determines whether the reference value points to the same object.
B. == The operator determines whether the contents and types of two separate objects are consistent.
C. Equals () method Returns true only when the content of the two objects.
D. Class File Rewriting Method Equals () Returns true when the contents and types of the two separate objects are consistent.
Strictly, the answer to this question is uncertain, because the equals () method can be overloaded, but according to the original Java language: If there is no override new class Equals (), In the same way, the two variables point to the same object, but Java recommended is whether the contents of the two objects are used to determine whether the contents of the two objects are the same as the Equals () method of the String class. : Determines whether the contents of the two String objects are the same, and the unique condition for returning TRUE is the same as the same object. In this sense, you will choose a given answer. From a stricter meaning, the correct answer should only be D.
11, Which Statements About Inheritance Are True?
A. In Java Programming Language Only Allows Single Inheritance.
B. In Java Programming Language Allows a Class to Implement Only ONE Interface.
C. in Java Programming Language A Class Cannot Extend A Class and Implement A Interface Together.
D. In Java Programming Language Single Inheritance Makes Code More Reliable.
(AD)
Title: What describes which describe inheritance is correct.
A. Only single inheritance is allowed in Java.
B. A class in Java can only implement an interface.
C. A class in Java cannot inherit a class and implement an interface.
D. Java's single inheritance makes the code more reliable.
A class in Java can only have a direct parent class, but you can implement multiple interfaces. Inheriting the interface, the reason why the inheritance can be canceled is multi-inheritance makes the code a lot of problems, and the use of single inheritance can be Make the code more reliable.
12,
1) Class Person {
2) Public void PrintValue (int i, int j) {/ * ... * /}
3) Public void PrintValue (INT I) {/*...*/}
4)}
5) Public class teacher extends Person {
6) Public void printvalue () {/*...*/}
7) Public void PrintValue (INT I) {/ /}
8) Public static void main (string args []) {
9) Person t = new teacher ();
10) T.PrintValue (10);
11)}
12)}
Which Method Will The Statement Online 10 Call?
A. Online 2
B. On line 3c. On line 6
D. on line 7
(d)
Title: What methods will be called for the declaration of the tenth line.
The variable T is a Person object, but it is instantiated with Teacher. This problem involves the multi-state and running polymorphism of Java. When compiling, T is actually a Person class, This involves automatic conversion of types (assigning an instance of a sub-class to a variable of a parent class without a mandatory type conversion. If this example, the runtime system will not pass when the method is called in the subclass, and when running, the runtime system will call the corresponding method according to the type of Type That. For this example, T.Print (10) will call T actually point to the corresponding method of the Teacher class. In Java, a variable of the parent class can be used in an instance of a subclass, and the variable is a parent class instance when compiling, which may be a subclass example at runtime.
13, Which Are Not Java Primitive Types?
A. SHORT
B. Boolean
C. Unit
D. float
(BC)
Title: Which below is not Java's raw data type.
Java's raw data type is eight, namely: Byte, Short, Int, Long, Boolean, Char, Float, Double. Note that these are sensitive, while Boolean is a Boolan package class.
14. Use the Operators "<<", ">>", Which Statements Are True?
A. 0000 0100 0000 00 00 00 00 00 00 00 << 5 gives
1000 0000 0000 00 00 00 00 00 00 00 00 0000 0000
B. 0000 0100 00 00 00 00 00 00 00 0000 << 5 gives
1111 1100 0000 0000 聽 000 00 00 00 0000 0000
C. 1100 0000 0000 00 00 00 00 00 00 00 >> 5 gives
1111 1110 0000 00 00 00 00 00 00 0000
D. 1100 0000 00 00 00 00 00 00 00 0000 >> 5 GIVES
0000 0110 0000 00 00 00 00 00 00 00 00
(AC)
Topic: Use "<<" and ">>" operations which statements are right.
There are three kinds of Java shift operators, namely ">>", ">>>", "<<", executed operations are signed right, no symbol right shift, left shift, have symbol right Move means that the highest level of the movement and the original highest symbol are the same, no symbol right shift is the transfer in the position, the lowest bit is always completed, and the highest level is abandoned. The other very worthless of the shift operator is that the right operand is the mode operation. It means that for an INT type data, the result of shifting the 32-bit to it is constant rather than zero. That is: A >> 32 results are A rather than 0, the same, the log type is the model of the right operation number 64, A >> 64 == a; there is a point to note is the shift operation ">>>" Only valid for int type and long type, the operation of BYTE or SHORT will result in automatic type conversion, and is a symbol. 15. Which of the folloading range of int is correct?
A. -27 - 27-1
B. 0 - 232-1
C. -215 - 215-1
D. -231 - 231-1
(d)
Title: What is the value of INT?
The INT type is 32-bit. See the discussion of the first question.
16, Which Keyword SHOULD BE Used to Enable Interact? The Lock of An Object? The flag allows Exclusive access to this object.
A. TRANSIENT
B. Synchronized
C. Serialize
D. static
(b)
Title: Which keywords below are usually used to lock objects, which makes access to objects.
Since Java is a multi-threaded language, multiple threads can "simultaneously" access the same data area, and do not want other threads when handling certain data, or some operations are uninterrupted. This, you can use the synchronized keyword to declare this.
17, Which is the return type of the method main ()?
A. Int
B. Void
C. Boolean
D. static
(b)
Title: What is the return type of main () method?
In Java, the entry running in the program is the main () method, which must be in the form: public static void main (String args []). However, strictly speaking the answer to this topic can also add A and C because there is no way to be a main () method of the program entry, and the main () method is overloaded. In general, main () of course refers to the main () method we just started.
18, Given The Following Code:
IF (x> 0) {system.out.println ("first");}
ELSE IF (x> -3) {system.out.println ("second");}
Else {system.out.println ("third");}
Which Range of X Value Would PRINT The STRING "SECOND"?
A. x> 0
B. X> -3
C. x <= -3
D. x <= 0 & x> -3
(d)
Title: Give the following code:
...
The value of X will print "Second" when the value is within the range. X> 0 Print "First", X> -3 && x <= 0 Print "Second", print "Third" at X <= - 3.
This topic is not difficult, just understand the syntax of the IF statement.
19, Given The Following Expression About TextField Which USE A ProPORTIONAL PITCH FONT.
TextField T = New TextField ("They Are Good", 40);
Which Statement Is True?
A. The Displayed String Can Use Multiple Fonts.
B. The Maximum Number of Characters in A Line Will BE 40.
C. The Displayed Width Is Exactly 40 Characters.
D. The User Can Edit The Characters.
(d)
Title: The following is given to the expression of TextField with a font using the appropriate character spacing.
...
What are the description?
A. A variety of fonts that are displayed can be used.
B. The largest number of characters in a row is 40
C. The width of the display is exactly 40 characters wide.
D. Users can edit characters.
For the constructor of this form of TextField, the previous parameter is the display value of the initial string in the text field, and the latter is the recommended display width, indicated by the number of numbers, the size of the text will Set to the best size, if the container limit makes the text domain can not display so much, it is generally bigger than this size, and even if the width is small, you can also enter a long line in the text field. String, only you don't use the carriage return, the text domain will automatically appear horizontal scroll bars over the display width (not set to off, the default is not closed), and the default edit mode of the text domain is editable One text field can only use a font, which can be dynamically changed during operation, but all strings in the text domain will use this font display.
20, Which Statements About The Garbage Collection Are True?
A. The Program Developer Must Create A Thread to be responsible for free the memory.
B. The Garbage Collection Will Check for And Free Memory No longer needed.
C. The Garbage Collection Allow The Program Developer to Explicity and Immedierately Free The Memory.
D. The Garbage Collection CAN Free The Memory Used Java Object At Expect Time.
(b)
Title: What describes the garbage collection is right.
A. Program developers must create a thread to work in memory release.
B. Garbage collection will check and release the no longer used memory.
C. Garbage collection allows program developers to explicitly designate and immediately release the memory.
D. Garbage collection can release the memory used by Java objects in the expected time.