Declaration, Initialization and Scoping for Java
The following is a summary for showing Java declaration, initialization and scoping.
- Variables defined in try block are not visible in catch block.
- You cannot pass parameters when you implement an interface by an anonymous class.
- Constructors cannot return anything. Not even void.
- Every enum has a values() method that returns an array of all the values in that enum in the order they are defined.
- System.out.println(0x10 + 10 + 010); Hexadecimal values can be denoted by prefixing with 0x ( Zero and upper or lower case 'x ') so 0x10 is equivalent to 16 decimal. Octal values can be denoted by prefixing with 0 ( Zero ) so 010 is equivalent to 8 decimal. The whole expression will be evaluated to 34 ( 16+10+8).
- Variables cannot be declared synchronized. Only methods can be declared synchronized.
- Any class can be declared abstract.
- Non static methods can access static as well as non static methods of a class.
- Only one public class can be defined in a file.
- To construct a Base class, it's super class needs to be constructed first. So some constructor of the super class has to be called. Either you explicitly call it or the compiler will add super() (ie. no args constructor) as the first line of the sub class constructor. Now, if the super class does not have a no-args constructor, the call super() will fail. Instead of calling super(...) you can also call another constructor of the base class in the first line.
-.
- The construct '{ }' is a compound statement. The compound statement can contain zero or more arbitrary statements. Thus, { { } }, which is a compound statement containing one statement which is a compound statement containing no statement, is legal.
- 'static' and 'final' are valid modifiers for both 'variable' and 'method' declarations within a class.
- 'transient' and 'volatile' modifiers are only valid for 'variables'.
- 'abstract' and 'native' are only valid for 'methods'.
- Note: a class can have only have 'final', 'abstract' and 'public' as modifiers.
- A class can be extended unless it is declared final. While declaring a method, static usually implies that it is also final, this is not true for classes.
- An inner class can be declared static and still be extended. Notice the distinction. For classes, final means it cannot be extended, while for methods, final means it cannot be overridden in a subclass.
- The native keyword can only be used on methods, not on classes and instance variables.
<pre><code> String foo = "bar"; </code></pre>
Pingback: Corporate sales training Beijing()
Pingback: emotional intelligence training course online()
Pingback: experienced sales trainer()
Pingback: emotional intelligence training course online()
Pingback: private english teacher shanghai()
Pingback: sales trainer cork()
Pingback: sales trainer London()
Pingback: sales training company shanghai()
Pingback: sales trainer tips()
Pingback: easy English training Shanghai()
Pingback: sales training china()
Pingback: corporate sales training china()
Pingback: 免费Simple Java (非常简单的英文) | | Evolution Unit 进化Evolution Unit 进化()