Java Basic face Test (classic) __java

Source: Internet
Author: User

The first stage question bank

Basic Knowledge Section:

1. What is the JDK? What the JRE is.

A) A: Jdk:java Development kit. Jre:java run time environment.

2. What is the Java platform-independent nature.

A A: Java source files are compiled into the form of bytecode, no matter what system environment, as long as the Java virtual

The machine will be able to run this byte code file. That is, a place to write, run everywhere. That's the cross-platform nature of Java.

3. Configure the Java environment on a single computer, and what role path plays. How to configure.

A) A: path works in a DOS environment where you can use any location in the Bin folder in the JDK directory

Executable program to compile and execute Java programs.

b Find the path variable in the environment variable and add the absolute path to the Bin folder.

4. What kind of identifiers are legal.

A) consists of letters, numbers, _ and $, not limited in length. Where the letters can be uppercase or lowercase English letters, number

The word is 0 to 9.

b The first character of the identifier cannot be a number.

c) identifiers are case-sensitive.

d) identifiers cannot contain spaces.

5. Java has several basic data types.

A) byte,short,int,long,char,boolean,float,double

6. What is implicit type conversion. What is display type conversion.

A) Java automatically uses implicit type conversions when assigning a less-occupied type to a more-occupied type. b when assigning the value of a variable of a higher level to a level bottom variable, you must use a display type conversion operation.

7. && and & difference, | | and | The difference.

A) && and | | is short circuit with, short-circuit or, when the left expression can determine the current result, then do not judge the right table

Up to the style.

B and & and | Then the results are calculated after the expressions on both sides are finished.

8. Break,continue difference.

A The break ends the most recent cycle, continue ends when the cycle enters the next loop.

9. What are the naming rules for classes?

A If the class name uses the Latin alphabet, then the first letter of the name uses the uppercase letter.

b The best name for the class name is proud, when the class name is compounded by several words, the first letter of each word uses uppercase.

10. The contents of a class body consist of two parts, which are two parts.

A part is the definition of the variable, used to characterize the attribute.

b The other part is the definition of the method used to characterize the function.

11. Explain what is a class member variable, local variable, instance member variable, class member variable.

A the variables defined in the variable definition section are called member variables of the class.

b The parameters of the variables and methods defined in the method body are called local variables.

c) member variables are divided into instance member variables and class member variables (static adornments).

12. Briefly describe this keyword usage.

A The This keyword is used in an instance method to represent the current object that invokes the method.

13. How to determine the return type of the method.

_____________________________________________________________________

A the type of the value returned by the method is the return type of the method and, if there is no return value, the return type is void.

14. The return value of the method of void is possible.

A) can. But there is no value after return.

15. Explain what is a class method and what is an instance method.

A The static modification method is a class method, and a method without static modification is an instance method.

16. Describe methods and variable naming rules.

A the first letter uses lowercase, if it consists of more than one word, use uppercase letters starting with the first letter of the 2nd Word.

17. What is a method overload.

A method overload means that multiple methods can have the same name in a class, but the parameters of these methods must not

The same, that is, or the number of parameters is different, or the type of parameter is different.

18. What is the construction method.

A The construction method is a special method whose name must be exactly the same as the name of the class in which it is located and does not return

Back to any data type.

19. How to create an object.

A to allocate memory for an object using the new operator and the constructor of the class, if there is no construction method in the class, the system

The default construction method is invoked.

20. In what circumstances will the system provide a constructor for the class, and what method of construction is provided.

A if there is no construction method in the class, the system provides a default construction method, the default constructor is the parameterless

Of

21. How the object invokes its own member variables and methods.

A) using operators ". "To invoke its own member variables and methods.

22. Why you can access class member variables and class methods directly using the class name.

A because when the class is loaded into the virtual machine, the class member variable is allocated memory, and the class method is assigned to the entry

, so you do not have to create the object, you can invoke it directly through the class name.

23. What are the characteristics of class variables?

(a) All objects of a class share the same class variable.

24. What are the characteristics of the class method?

A The class method can only invoke class variables and class methods. (in the same class)

What is the role of the package keyword and what is the problem to be noticed in use?

A package specifies the package in which the class resides, which is the first line of the source code.

The Import keyword has any effect.

A to introduce the classes used in the program.

27. Classes have several access rights. Variables and methods have several access rights. What is the difference.

A the class has two access rights: public, friendly.

b Methods and variables access rights: public,protected, Friendly, private.

28. Briefly describe the access rights of Java.

(a) Public: publicly available, accessible by any class.

b) Protected: Protected, the same package class can be accessed. Subclasses of different packages can be accessed. c) Friendly: classes of the same package can be accessed.

D Private: Proprietary, accessible in the same class.

29. Subclasses can inherit which variables and methods of the parent class.

A if the subclass and the parent class are in the same package, then the subclass naturally inherits from its parent class that is not private

A member variable is a member variable of its own, and it naturally inherits a method that is not private in the parent class as its own method.

_____________________________________________________________________

b if the subclass and the parent class are not in the same package, then the subclass inherits the Protected,public of the parent class

The member variable is a subclass of the membership variable, and inherits the Protected,public method of the parent class as a subclass of the method.

30. Subclasses override the method of the parent class to reduce access rights.

A) cannot be lowered.

The final keyword can be used to modify what. What the difference is.

A The final can modify the class so that the class cannot be inherited.

(b) Final can modify the method, such a method cannot be overridden.

(c) Final can modify the variable, such that the value of the variable can not be modified, is a constant.

32. Brief description of Super keyword function.

A to invoke the constructor method of the parent class using Super.

(b) member variables and methods that are hidden using the super operation.

33. Briefly describe what is the transformation of the object.

A) Suppose that Class A is the parent class of Class B, when we create an object with a subclass and place the reference of the object

Into the object of the parent class, we call the parent class object to be the transition object of the subclass object.

34. What can be manipulated on the transition object. You can't manipulate anything.

A the up-turn object cannot manipulate the new member variable of the subclass, losing this part of the property and not using the subclass new

method, and has lost some function.

b The Transition object can manipulate a member variable inherited or overridden by a subclass, or you can use a subclass inherited or overridden

Method.

35. What is an abstract class. What is an abstract method. What are the characteristics.

A the abstract class cannot be created with the new operation by using the keyword abstract modifier class, which must be

Produces its subclass, and the subclass creates the object.

(b) using the keyword abstract modification method called an abstract method, which allows only declarations, and does not allow

Realize.

36. A class declaration implements an interface, so what does this class need to do.

A to implement all the methods in the interface, and the access rights of these methods must be public.

37. Briefly describe what an array is.

A The array is a composite data type of the same type of data in order. Addends group subscript by array name,

To use the data in the array. The subscript is sorted starting at 0.

38. Whether to create an array requires specifying the length of the array, and how to find the array length.

A the array length must be specified, array calls. length to get the length of the array.

How the array of chars and byte arrays are converted into strings. How to find the string length.

(a) using the construction method of the string class itself, string (char a[]), String (byte a[]), "". Length ().

The following methods are the methods in the string

equals Equalsignorecase startswith EndsWith

A) string comparison.

b) ignores case comparison.

c) to determine whether to start and end with the specified string.

Regionmatches

A determines whether a substring of a string matches a substring of another string.

CompareTo Comparetoignorecase indexOf

A) compares strings in dictionary order.

b ignores case-by-dictionary comparisons of strings.

c) string retrieval.

Substring Replace trim ()

A) string interception

b) String substitution

C Remove the space before and after the string.

44. How the string is converted to int, double type.

A) Integer.parseint ("1");

b) double.parsedouble ("25"). 45 ");

45. Briefly describe the role of StringTokenizer.

A the string is parsed into several language symbols according to the specified delimiter.

46. How to judge a character is not a number, is not uppercase.

A) character.isdigit (' a ')

b) character.isuppercase (' U ')

47. Known a Java.util.Date object, how to format it in the following format Yyyy-mm-dd HH:MM:SS

a) SimpleDateFormat formate = new SimpleDateFormat ("Yyyy-mm-dd HH:mm:ss");

Formate.format (New Date ());

48. How to generate a 0-100 of the immediately integer.

a) (int) (Math.random () *100)

49. Briefly describe the mechanism of Java exception handling.

A the caller can catch the exception for processing when the method being invoked has an exception, or it can bypass the exception.

50. Brief description of the following keyword use try, catch, throw, throws, finally

A try: Protects the code, and if a line of code in the try has an exception, the code in the try does not continue. Catch: Catches the exception, and when an exception occurs in try, the catch is responsible for catching the exception and handling it.

c) Throw: throws an exception.

D) throws: declaring an exception.

(e) Finally: Finally, regardless of whether an exception occurs in a try, it must be executed.

The difference between LinkedList and ArrayList.

A The LinkedList bottom is implemented through a chain-type storage structure.

b The ArrayList bottom is implemented by array.

52. What is the I/O stream, what is the effect.

A) refers to the flow of data input and output, I/O flow provides a channel program, you can use this channel to the source of the word

The section sequence is given to the destination.

53. How to view the size of a file, absolute path, whether readable.

A) file File = new file ("E://a.txt");

b) File.length ();

c) File.getabsolutepath ();

d) File.canread ();

54. The following code is known

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.