July 29, 2021

Java Interview Tips to Remember

Java Interview Tips to Remember

Java is a programming language originally developed by James Gosling at Sun Microsystems which is now a subsidiary of Oracle Corporation and released in 1995 as a core component of Sun Microsystems Java platform. The language derives much of its syntax from C and C++ but has a simpler object model and fewer low-level facilities. Java applications are typically compiled to bytecode (class file) that can run on any Java Virtual Machine (JVM) regardless of computer architecture. Java is a general-purpose, concurrent, class-based, object-oriented language that is specifically designed to have as few implementation dependencies as possible.

Here are some of the important Java Interview tips to remember :

1)  What is the use of bin and lib in JDK?

A) Bin contains all tools such as javac, appletviewer, awt tool, etc., whereas lib contains API and all packages.

2) What’s the difference between constructors and other methods?

A) Constructors must have the same name as the class and can not return a value. They are only called once while regular methods could be called many times.

3) Can an inner class declared inside of a method access local variables of this method?

A) It’s possible if these variables are final.

4) What is casting?

A) Casting is used to convert the value of one type to another.

5) What is UNICODE?

A) Unicode is used for internal representation of characters and strings and it uses 16 bits to represent each other.

6) What is Garbage Collection and how to call it explicitly?

A) When an object is no longer referred to by any variable, java automatically reclaims memory used by that object. This is known as garbage collection. System. gc() method may be used to call it explicitly.

7) What comes to mind when someone mentions a shallow copy in Java?

A) Object cloning.

8) What is HashMap and Map?

A) Map is Interface and Hashmap is class that implements that.

9) What is finalize() method?

A) finalize () method is used just before an object is destroyed and can be called just prior to garbage collection.

10) What is the difference between String and String Buffer?

A) a) String objects are constants and immutable whereas StringBuffer objects are not.

     b) String class supports constant strings whereas StringBuffer class supports growable and modifiable strings.

11) What is a package?

A) A package is a collection of classes and interfaces that provides a high-level layer of access protection and name space management.

12) What is a reflection package?

A) java. lang. reflect package has the ability to analyze itself in runtime.

13) What’s the difference between Thread and Runnable types?

A) A Java Thread controls the main path of execution in an application. When you invoke the Java Virtual Machine with the java command, it creates an implicit thread in which to execute the main method. The Thread class provides a mechanism for the first thread to start-up other threads to run in parallel with it.

14) What is the difference between Integer and int?

A) a) Integer is a class defined in the java. lang package, whereas int is a primitive data type defined in the Java language itself. Java does not automatically convert from one to the other.

     b) Integer can be used as an argument for a method that requires an object, whereas int can be used for calculations.

15) What is a cloneable interface and how many methods does it contain?

A) It is not having any method because it is a TAGGED or MARKER interface.

For Java Online Training please visit http://www.revanthtechnologies.com