Logo F2FInterview

Java Interview Questions

Q   |   QA

Yes a single source file can contain any number of Class declarations but only one of the class can be declared as public.

Package is a collection of related classes and interfaces. package declaration should be first statement in a java class.

java.lang package is imported by default even without a package declaration.

Instance variables are those which are defined at the class level. Instance variables need not be initialized before using them as they are automatically initialized to their default values.

The variable should be declared as static and final. So only one copy of the variable exists for all instances of the class and the value can't be changed also.
static final int PI = 2.14; is an example for constant.

In order to link this F2FInterview's page as Reference on your website or Blog, click on below text area and pres (CTRL-C) to copy the code in clipboard or right click then copy the following lines after that paste into your website or Blog.

Get Reference Link To This Page: (copy below code by (CTRL-C) and paste into your website or Blog)
HTML Rendering of above code: