Logo F2FInterview

Java Basics Interview Questions

Q   |   QA

The thread could be implemented by using runnable interface or by inheriting from the Thread class. The former is more advantageous, 'cause when you are going for multiple inheritance, the only interface can help.

Yes the imports are checked for the semantic validity at compile time. The code containing above line of import will not compile. It will throw an error saying, can not resolve symbol

symbol : class ABCD

location: package io

import java.io.ABCD;

No you will have to import the subpackages explicitly. Importing com.MyTest.* will import classes in the package MyTest only. It will not import any class in any of it's subpackage.

In declaration we just mention the type of the variable and it's name. We do not initialize it. But defining means declaration + initialization.

Example: String s; is just a declaration while String s = new String ("abcd"); Or String s = "abcd"; are both definitions.

The default value will be null unless we define it explicitly.

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: