Core Java Interview Questions Part 14/Packages and Exception handling.

Hello Friends, In this Blog Post I am going to let you know about a few more interview questions of core java related to Packages and Exception handling.

Core java interview questions cover all the important questions of the topics mentioned above.

These core java interview questions are a great help to remember all the important highlights and important topics from each java chapter.

These interview questions will surely help to understand a few very confusing concepts in java.

A programmer is writing the following statements in a program?

1. import java.awt.*;
2. import java.awt.*event.*;

Should he write both the statements in his program or the first one is enough?

event is a sub package of JAVA.AWT package. But when a package is imported, its sub-packages are not automatically imported into a program. So, for every package or sub-packages, a separate import statement should be written.

Hence the programmer wants the classes and interfaces of both the JAVA.AWT and JAVA.AWT.event packages, then he should write both the preceding statements in his program.

How can you call the garbage collector?

We can call the garbage collector of JVM to delete any unused variables and unreferenced objects from memory using GC() method. This GC() method appears in both runtime and system classes of java.lang package. For example, we can call it:



The CLASSPATH is an environment variable that tells the java compiler where to look for class files to import. CLASSPATH is generally set to a directory or a jar(java archive) file.

What is the JAR file?

A java archive file(JAR) is a file that contains a compressed version of several.class files, audio files, images files, or directories. JAR file is useful to bundle up several files related to a project and use them easily.

What is the scope of the default access specifier?

Default members are available within the same package, but not outside of the package. so their scope is package scope.

What happens if the main() method is written without string args[]?

The code compiles but JVM can not run it, as it can not see the main() method with string args[].

What are the checked exceptions?

The exceptions that are checked at compilation time by the java compiler are called ‘checked exceptions’ The exceptions that are checked by the JVM are called ‘unchecked exceptions’.

What is throwable?

Throwable is a class that represents all errors and exceptions which may occur in java.

What is the superclass for all exceptions?

The exception is the superclass of all exceptions in java.

What is the difference between an exception and an error?

an exception is an error that can be handled. It means when an exception happens, the programmer can do something to avoid any harm. But an error is an error that can not be handled, it happens and the programmer can not do anything.

What is the difference between throws and throws?

The Throws clause is used when the programmer does not want to handle the exception and throws it out of a method. A throwing clause is used when the programmer wants to throw an exception explicitly and wants to handle it using a catch block. Hence, throws and throws are contradictory.

It is possible to re-throw exceptions?

Yes, we can re-throw an exception from catch block to another class where it can be handled.

So this was all about the Core java interview questions on this topic.

These Core java interview questions could be a great help in your college viva, academic study, and any job interview.

In the case of any queries, you can write to us at [email protected] we will get back to you ASAP.

Hope! you would have enjoyed this post about Core Java Interview Questions Part 14/Packages and Exception handling.

Please feel free to give your important feedback in the comment section below.

Have a great time!


I am a blogger by passion, a software engineer by profession, a singer by consideration and rest of things that I do is for my destination.