Core Java Interview Questions On 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.|Core Java Interview Questions On Packages and Exception Handling |

These core Java interview questions are a great help to remember all the important highlights and important topics from each Java chapter.|Core Java Interview Questions On Packages and Exception Handling |

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 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-package, 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 the GC() method.

This GC() method appears in both runtime and system classes of Java.lang package. For example, we can call it:

system.GC();
Runtime.get runtime().gc();

What is CLASSPATH?

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, image 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 the 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.

You can also go through a few more amazing blog links related to core Java interview questions:

Core Java Interview Questions Part 1
Core Java Interview Questions Part 2
Core Java Interview Questions Part 3
Core Java Interview Questions Part 4
Core Java Interview Questions Part 5
Core Java Interview Questions Part 6
Core Java Interview Questions Part 7
Core Java Interview Questions Part 8
Core Java Interview Questions Part 9
Core Java Interview Questions Part 10
Core Java Interview Questions Part 11
Core Java Interview Questions Part 12
Core Java Interview Questions Part 13
Core Java Interview Questions Part 14
Core Java Interview Questions Part 15
Core Java Interview Questions Part 16
Core Java Interview Questions Part 17
Core Java Interview Questions Part 18
Core Java Interview Questions Part 19
Core Java Interview Questions Part 20
Core Java Interview Questions Part 21
JVM In Hindi: Java Virtual Machine
C ++ और Java में अंतर हिंदी में…

In the case of any queries, you can write to us at a5theorys@gmail.com 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!

Anurag

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.