Hill blog - answer interview questions

Win in Interview Java Basics (1)

1. There can be multiple classes, but only one public class, and the public class name must match the file name.

2.java have goto, but is a reserved word, it has not yet been applied

3. The same point: & && and can be used as the logical AND operator, and represents a logical (and), when the result of the expression of both sides of the operator are true overall result is true

 Different points: && short-circuit function, i.e., a first false expression is not in the second expression; & bitwise operators may also be used, when the boolean expression is not & operator both sides, represented by & bit operation, as a result a 1 & 3

4. break out of the loop using a keyword, multi-loop out marker may be used outermost loop, outer loop or a memory cycle can be controlled

5.switch be applied to char byte short int and the corresponding packaging, can not act on long double float boolean and their packaging

6. For short s1 = 1; s1 = s1 + 1; since s1 + automatically elevated expression of type 1 operation, so the result is an int, s1 then assigned to the short type, the compiler would report requires cast type mistake.

 For short s1 = 1; s1 + = 1; a = + Since a predetermined java language operators, it will java compiler special treatment, it is possible to correct translation. 

7 can, as char type variable is used to store the Unicode characters, Unicode coded character set contains characters, a char type variable characters may of course be stored in it. However, if a special unicode characters not included in the coded character set, then the char type variable can not be stored in the special characters

8. Use Bitwise 2 << 3

9. If final modification is the basic data type of a variable, the value of this variable on the set, can not be changed, and if the modification is a reference variable, then the variable is stored in a memory address, the address will not be It changed, but that the memory address of the object pointed to or can become, just like you remember people's house number, but you can not control the number of people at home personnel.

10. a. Static variables (class variables) to increase the static keyword before, instance variables (member variables) are not added before

  b. Static variables belong to a class, the class name directly point to use, real-column variable belonging to the object, the object must be to point

  c. Static variables present in the process region, in the present instance variable stack

Win in Java Basics Interview (2)

11. not. Because the non-static method is associated with the object to be together, after you must create an object, it can invoke a method on the object, and the object does not need to create a static method call, can be called directly.

12.a.int is a basic data type, Integer is a corresponding packaging int

  B.int default value is 0, Integer default value is null

    c, Integer is a reference to the actual object, and int is directly stored data value.

12 and 13. The result is a method -11 Math.round (11.5) may be understood as +0.5 number in parentheses after the down value,

  Math.ceil find the smallest integer not less than itself but rounded up ---

  Math.floor seeking the greatest integer, but not more than itself. Rounding down ----

  Math.round seeking rounding itself.

  Math.abs absolute value itself.   

14.Overload is overloaded, occur in the same class, the same method name, a list of different parameters, return value type can not be changed Overload

   Override rewrite occurs in the parent-child class, the name of the same method, the same list of parameters, the method body different

  

 

 

 

 

 

 

 

Guess you like

Origin www.cnblogs.com/zblwyj/p/11903962.html