The purpose of writing this article is to summarize the knowledge points of learning java and help others learn java. I personally feel that java is indeed a good programming language, to learn java well, you must first master the features of java. These features can be fully reflected in the scjp set of questions, and the knowledge points of the set of questions are in place, these questions must be well understood in java.
If there is any error in this article, please correct me! If you have any questions related to this article, please feel free to contact us. Thank you.
1. Which of the following range of short is correct? A.-27 -- 27-1 B .0 -- 216-1 C .? 215 -- 215-1 D .? 231 -- 231-1 Which of the following are the short value ranges. Answer C Parsing The length of the short integer data type is 16 bits, signed. In addition, it should be noted that all integer numbers (including byte, short, int, and long) in java are signed.
2. Which declarations of identifiers are legal? A. $ persons B. TwoUsers C. * point D. this E. _ endline Which of the following are valid identifiers for translation. Answer Analysis of A, B, E Java identifiers can start with a Unicode character, underscore (_), and dollar sign ($). Subsequent characters can be symbols and numbers in front, with no length restrictions and are case sensitive, it cannot be a reserved word.
3. Which statement of assigning a long type variable to a hexadecimal value is correct? A. long number = 345L; B. long number = 0345; C. long number = 0345L; D. long number = 0x345L Translate which is to assign a hexadecimal value to a long variable. Answer D Parsing
The hexadecimal number starts with 0x, and the long number is L (both uppercase and lowercase are allowed, because the lower-case l and number 1 are not easy to distinguish ).
4. Which of the following 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 ";
Which of the following program fragments may cause errors. Answer B and D A: The String type can be directly connected using +.
B: String is an Object rather than a simple character array. It cannot be an element of its value using the subscript operator. It is incorrect.
C: The toUpperCase () method is a String object method. It converts all the content of a String to uppercase and returns the converted result (String type ).
D: The String type cannot be used for the minus (-) operation. An error occurs.
5. Which are syntactically valid statement at // point x? Class Person { Private int; 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 } }
A. I = m;
B. I = B; C. I = p.; D. I = p. change (30 ); E. I = t. B. Which statements of translation at // point x are syntactically legal. Answer D, E Analysis A: m has not been declared and cannot be used. B: Although B is a public member variable of the Teacher Class, non-static members in the class cannot be used in static methods. C: a is a private member of the class Person and cannot be directly referenced outside the class. D: The change (int m) method is a public method and returns an int value. You can reference and assign a value to an int type variable through instance variable p of the class. E: B is a public member variable of the Teacher Class and is of the int type. It can be referenced and assigned to an int type variable through the instance variable t of the class.
6. Which layout manager is used when the frame is resized the buttonss position in the Frame might be changed? A. BorderLayout B. FlowLayout C. CardLayout D. GridLayout The layout manager used when the Frame size is changed and the button position in the Frame may be changed. Answer B Parsing A: The layout manager divides the container into five parts. Changes in the container size will not affect the location of the components but the size of the components. B: The layout manager adjusts the position of the component based on the most suitable size of the component to be put in. The layout manager arranges the position according to the order in which the component is put. When one row cannot be accommodated, the layout manager places the next row, therefore, changing the container size may change the component location. C: The layout manager displays the components on the current page of the container. One component is displayed at a time. Changes in the container size cannot affect the component position. D: The layout manager divides containers into fixed grids, and components occupy a unit after they are added. The relative positions of each component are not changed because of the container size, only the component size is changed.
7. Given the following code fragment: 1) public void create (){ 2) Vector myVect; 3) myVect = new Vector (); 4 )} Which of the following statements are true? A. The declaration 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 on line 2 creates an object of class Vector. D. The statement on line 3 creates an object of class Vector. E. The statement on line 3 allocates memory space for an object of class Vector Translation The following code snippet is provided... Which of the following statements are true )? A. the Declaration in the second line will not allocate memory space for the variable myVect. B. the Declaration in the second row allocates a reference memory space to the Vector object. C. The second line of the statement creates a Vector object. D. Create a Vector object using the statement in the third row. E. The statement in the third line allocates memory space for a Vector object. Answer A, D, E The SL-275 states that new Xxx () calls must be executed to allocate space for a new object, and new calls do the following:
1. Allocate space for the new object and initialize its members to 0 or null. 2. Perform initialization in the class body. (For example, if a member declares int a = 10 in the class, a = 0 after step 1, and a = 10 after step 2) 3. Execute the constructor. 4. The variable is assigned as a reference to a new object in the memory heap.
8. Which of the following answer is correct to express the value 8 in octal number? A. 010 B. 0x10 C. 08 D. 0x8 Translation Which of the following answers can be used to indicate the octal value of 8. Answer A Parsing The octal value starts with 0 and 0x is a hexadecimal value. The octal value cannot contain digits 8, and the maximum value is 7.
9. Which are not Java keywords? A. TRUE B. sizeof C. const D. super E. void
Translation Which are not Java keywords. Answer A and answer B A: No. Java has true, but this is not A keyword but A literal ). B: No. This operator is not required in Java. The size of all types (original types) is fixed. C, D, and E are both. Note that const is a keyword not used in java.
10. Which of the following 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 two 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. Translation Which of the following statements are true. A. equals () method determines whether the reference value points to the same object. B. = operator determines whether the content and type of two discrete objects are consistent. The C. equals () method returns true only when the content of the two objects is consistent. D. Class File Rewriting Method equals () returns true when the content and type of two discrete objects are consistent. Answer A and D Strictly speaking, the answer to this question is uncertain, because the equals () method can be reloaded, but according to the java language's intention: override) equals () of the new class, the method returns true when two variables direct to the same object like the = Operator, but equals () is recommended in java () method to Determine whether the content of the two objects is the same, as the equals () method of the String class does: Determine whether the content of the two String objects is the same, the only condition for the = Operator to return true is that two variables direct to the same object. In this sense, select the given answer. In a more rigorous sense, 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. Translation Which of the following statements about inheritance are true.
A. Only A single inheritance is allowed in java. B. A class in java can only implement one interface. C. A class in java cannot inherit a class and implement an interface at the same time. D. The single inheritance of java makes the code more reliable. Answer A and D In java, a class can only have one direct parent class, but multiple interfaces can be implemented, while interfaces can be inherited, the reason for Canceling Multi-inheritance is that multi-inheritance creates many problems in the Code, while using a single inheritance can 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 {
|