Top 20 Tricky Java interview questions and Answers

Page 1

70-70-90-59-90 www.ducatindia.com

Q: What is Java

Ans: Java is a high-level, object-oriented, reliable, secured, slightly elevated, multiprocessing, and adaptable programming language. It is also platform-independent. In June 1991, James Gosling created it. Because it offers its very own JRE & API, it may also be referred to as the platforms.

Q : Whichoneissuperclassofall classes?

Ans:Java.lang. There is no need to upgrade the object because it serves as the base class including all Java classes. The objects is the base class for all other Java classes. Arrays are one of the several non-primitive classes that are either directly or indirectly derived from this class.

Q- What is the static keyword?

Ans: A class level variables is made global by using the static keyword, allowing all entities to utilize the same value. It may also be used to techniques. Only static classes elements and static class methods may be accessed or called by a static method.

Q- What is the use of Classloader in Java?

A Java program is made up of a different number of custom classes and pre-defined classes. When a program is executed, JVM is used to load all the content of that needed class and through the use of Classloader JVM, it finds that class. There are three types of Classloaders: 1. 2.

System Class Loader

It loads all the classes from the classpath. Extension ClassLoader

3.

Q- What are finally and finalize in Java?

Ans: Finally, a try-catch block is applied to code that should always be run even if the try-catch block throws an exception. Finally is only used to release the resources produced by the try block.

Finalize():

Finalize() is an Object class function which we can override in our classes. The garbage collector calls Finalize() to gather the trash value whenever the object receives it. Whenever a garbage value is gathered from an object, this function is usually overridden to free system resources.

Q- What is Type casting in Java?

Ans: Casting in Java is one of the most popular subjects for interview questions. Whenever we allocate a value from one dataset to a distinct data type, the two data kinds may be incompatible and require transformation. When data types are appropriate, for as when converting an int result to a long value, Java does automated transformation and does not need typecasting. However, if the data types are incompatible, they must be transferred for conversions.

Q- What is break and continue statement?

Ans: To end a while or do-while loop, we apply the break statement. To escape the switch case, we employ a break statement within a switch statement. We could also employ the break statement to end the stacked loop.

The continue statement is utilized to terminate a for, while, or do-while loop execution.

To ignore the current version of the topmost loop, we may employ the break statement with such a label.

NOTE:

The most basic programming question, not only related to the Java. If you have some knowledge of programming languages, you should know the answer to this question as it is among frequently asked Java interview questions for freshers.

Read More

Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.