Summary of questions in Java basic plane

Source: Internet
Author: User
Tags array length float double instance method

First, the basic knowledge


1.JDK and JRE

A: JDK Java Development Kit, JRE Java Runtime Environment.

2. Legality of identifiers

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

The word is 0 to 9. The first character of an identifier cannot be a number. Identifiers are case-sensitive and identifiers cannot contain spaces.

How many basic data types does 3.Java have?

Answer: byte short int long char Boolean float double

4. What is implicit type conversion? What is the display type conversion?

A: Java automatically uses implicit type conversions when assigning a type with a small number of placeholders to a multiple-occupied type. The display type conversion operation must be used when assigning the value of a variable at a high level to a level bottom variable.

5.&& and & Differences, | | and | The difference between

Answer:&& and | | is short-circuited with and OR, when the left condition is established, is not judged on the right side of the condition. & and | are both sides of the conditions are calculated after the results.

The difference between 6.break and continue

A: Break ends the most recent loop. Continue end this cycle and enter the next cycle.

7. What is a class member variable, a local variable, an instance member variable, a class member variable

For:

A) variables defined in the variable definition section are referred to as member variables of the class.

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

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

8. What is a class method and what is an instance method

A: Class methods are decorated with static. The method without static modification is an instance method.

9. What is method overloading?

A: Method overloading means that a class can have multiple methods with the same name, but the parameters of these methods must not

Either the number of arguments or the type of the parameter is different.

10. What is a construction method?

A: A constructor is a special method whose name must be exactly the same as the name of the class in which it resides and does not return

Back to any data type.

11. What kind of construction method does the system provide for the class?

A: If there is no construction method in the class, the system provides a default constructor method, and the default constructor is to have no parameters.

Of

12. Why can I access class member variables and class methods directly with the class name?

A: When a class is loaded into a virtual machine, the class member variable is allocated memory, and the class method is assigned to the entry

The object is not created and can be called directly from the class name.

13. What are the characteristics of class variables?

Answer: All objects of a class share a class variable.

14. What are the characteristics of class methods?

A: Class methods can only invoke class variables and class methods.

Access rights for 15.java

A: Public, any class can be accessed.

Protected protected, classes of the same package can be accessed, and subclasses of different packages can access

Default the same package can be accessed

Private, which can be accessed in the same class.

16. What variables and methods can the subclass inherit from the parent class?

A: If the child class and the parent class are in the same package, the child class can inherit the member variable that is not private in the parent class as its own member variable, and also inherit the method that is not private in the parent class as its own method.

If the child class and the parent class are not in the same package, the subclass inherits the Protected,public member variable of the parent class as a member variable of the subclass and inherits the method of the parent class's Protected,public method as a subclass.

17. Subclasses override the parent class's methods, can you reduce access rights?

A: No, the subclass access permission must be greater than or equal to the parent class.

What can 18.final keywords be used to decorate? What role do they play separately?

A) Final can modify the class so that the class cannot be inherited.

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

C) Final can modify the variable, so that the value of the variable can not be modified, is a constant.

What is the role of 20.super keywords?

A) use Super to call the parent class's construction method.

b) Use super to manipulate the hidden member variables and methods.

21. What is the upward transition?

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

To the object of the parent class, we call this parent class object to be the upper-transition object of the subclass object.

22. What can I do with an upward transition object? What can not be done?

A: A) The object cannot manipulate the new member variables of the subclass, lose this part of the property, cannot use the new method of subclass, lost some function.

b) on a transformed object you can manipulate member variables that are inherited or overridden by subclasses, or you can use a subclass-inherited or overridden method.

23. What is an abstract class? What is an abstract method? What are the characteristics?

A) using the keyword abstract modifier class is called an abstract class, the abstract class cannot create an object with the new operation, it must produce its subclasses, and the child class creates the object.

b) using the keyword abstract modification method is called an abstract method, and the abstract method allows only declarations, not implementations.

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

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

25. Describe what an array is?

A: An array is a composite data type that consists of the same type of data in order. Use the array name Addend group subscript to work with the data in the array. The subscript is sorted starting from 0.

26. Do you want to specify the array length and how to find the array length?

A: You must specify the array length, and the array calls the length method to get the array lengths.

How do 27.char arrays and byte arrays translate into strings? How do I find the string length?

A: How to construct the string class itself, string (char a[]), String (byte a[]), "". Length ()

28.trim () What's the use?

A: Remove the space before and after the string.

29. How does the string convert to int type, double type?

Answer: a) integer.parseint ("1");

b) double.parsedouble ("25.45");

30. Describe the role of StringTokenizer?

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

31. How to tell if a character is not a number, is it uppercase?

Answer: Character.isdigit (' a ') character.isuppercase (' U ')

32. A Java.util.Date object is known, how to format it into the following format Yyyy-mm-dd HH:MM:SS

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

Formate.format (New Date ()));

33. Random number generation

Answer: Math.random ()

34.java exception handling mechanism

A: When an exception is called to a method, the caller can catch the exception to be processed or avoid the exception.

35.try, catch, throw, throws, finally keyword use

A) Try: Protect the code, and if a line of code in the try is an exception, the code in try no longer executes.

b) Catch: Catch Exception, when an exception occurs in try, the catch is responsible for catching the exception and processing.

c) Throw: throws an exception.

D) throws: Declares an exception.

E) Finally: Finally, no matter if there is an exception in the try.

36.LinkedList and ArrayList difference?

A: The LinkedList bottom layer is implemented through a chained storage structure. ArrayList the bottom layer is implemented by an array.

37.I/O Flow

A: Refers to the data input and output stream, I/O flow provides a channel program, you can use this channel to send a sequence of bytes from the source to the destination.

38. Two ways to implement multithreading?

A) inherit the Java.lang.Thread and rewrite its run () method.

b) Implement the Runnable interface, overriding the run () method in the Runable interface.

39. Describe the life cycle of a thread?

A: New---run---interrupted---death

40. How do I get a ready thread to run?

A: The Start method of the calling thread lets a thread in the ready state run.

41. How do I synchronize threads?

Answer: Lock, lock or synchronized

42. What is a GC? Why is there a GC

A: The GC is a garbage collector, and the garbage collector automatically manages the memory.

43. Can the construction method be rewritten? Why?

A: No, the construction method cannot be inherited.

44. Can I inherit the string class, and why?

Answer: No, because the string class is final decorated

What character set does 45.java use? How many characters the character set has

A: Java uses the Unicode character set, so there are 65,535 constants

46. What is the language of compilation execution? What is the language for interpreting execution?

A: A) Compile method: compilation: For the current machine processor chip, the source program all translated into machine instructions, called the target program, and then the target program to the computer execution.

b) Interpretation method: Interpretation: This method does not produce the whole target program, but according to the current machine processor chip, side translation side execution, translation of a sentence execution.

47. Describe the execution process of a Java program?

A) First write the Java source file (a text document with the extension. java).

b) Compile the source file into a bytecode file (. class file) with the Javac command

c) Execute the bytecode file with the Java command.

48.java three major features

Answer: encapsulation, inheritance, polymorphism

49. What is the function of the construction method?

A: When creating an object, the Java virtual Opportunity invokes the constructor of the class to create the object. The initialization of a generic object can be placed in a construction method.

50. What is the scope of the member variable? What is the scope of a local variable?

A) member variables are valid throughout the class

b) A local variable is only valid within the class in which it is defined.

Summary of questions in Java basic plane

Related Article

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.