Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

100 Core Java Interview Questions and Answers - Part 9

Here are top selected core Java interview questions asked in high level interviews, these questions may be helpful for both freshers or experienced professional going for interview.




81) What if, we import a class or package more than once in our program?

We can import a class or an package as many times as we want to, neither the compiler or the JVM will complain about it. But internally the class or package will be loaded once no matters how many times we have written the import statement.

82) What is the difference between a checked or unchecked exception in Java?

The classes which extends Throwable class except RuntimeException and Error are known as checked exceptions. These exceptions are thrown at compile time. E.g. IOException, FileNotFoundException etc. The classes which extends RuntimeException class are called unchecked exceptions. These exceptions are thrown at runtime. E.g. ArithmeticException,NullPointerException etc.

83) What is the root class of all Exception and Errors in Java.

Throwable is the base class for all Exceptions and Errors in Java.

84) Can we have a try block without a catch block in Java?

Yes, we can have a try block without having a catch block but a try block must be followed by either a catch or a finaly block or with both.

85) What are nested classes in Java?

A class that is declared inside another class is called nested class, there are four types of a nested class in java : member inner class, local inner class, annonymous inner class and static nested class.

86) What is volatile keyword in Java?

Threads hold their own copy of variables in local memory, if a variable is marked as volatile it means that the variable will be stored in main memory, every time a volatile variable is read it will be read from the main memory similarly every time the volatile variable is written the changes will be written to the main memory only.

87) What is the difference between path and classpath in java?

In context of java path and classpath both are operating system level environment variables. Path says where can the system finds .exe files whereas classpath tells the location of .class files within a system.

88) What do you mean by downcasting in Java?

In java downcasting means casting a general type to a more specific type.











Thanks for reading !
Being Java Guys Team




This post first appeared on Java, Struts 2, Spring, Hibernate, Solr, Mahout An, please read the originial post: here

Share the post

100 Core Java Interview Questions and Answers - Part 9

×

Subscribe to Java, Struts 2, Spring, Hibernate, Solr, Mahout An

Get updates delivered right to your inbox!

Thank you for your subscription

×