java interview points

Java Keywords and Identifier Naming Rules Quick Reference

This is a quick summary of important keywords and reserved words that you should not be using as an identifier. Identifier is a name given to any class, method, interface, enum or variable that we create. There is also added quick notes section with few important keywords that may be useful for exam or interview preparations.

 

Keywords in Java

  • class, interface, enum(added in 5.0), package, import, new, this,  super, return, void.

Class variables, Instance Variables and Local variables in Java

Based on the scope in which the variable is declared, we can classify variables as Class variables, Instance Variables and Local variables.

 

Class variables (or static variables)

Class variables (or static variables) are declared within a class and outside all methods using the static keyword.

Example: Static variable

class MyClass{

static int myVar;

Import Statements in Java

To access a class or method from another package we need to either use the fully qualified name (e.g. com.javajee.MyClass) or we can use the import statements.

 

Using import statement

You can use an import statement to import a single class (import java.util.List;) or all classes of a package (import java.util.*;). Remember that you can import only types (classes and interfaces, but not methods) using a regular import.

Consider an example:

Packages in Java

Packages are used in Java for organizing your class files. It can be considered as different folders to organize your files within your file system. You can put related class files together in one package. Java groups predefined classes into different packages like java.lang, java.util, java.io etc.

Search the Web

Custom Search

Searches whole web. Use the search in the right sidebar to search only within javajee.com!!!