November 7, 2018

Sreekanth B

Kaspersky Lab Most Frequently Asked Core Java Interview Questions Answers

What Are Some Alternatives To Inheritance?

Delegation is an alternative to inheritance. Delegation means that you include an instance of another class as an instance variable, and forward messages to the instance. It is often safer than inheritance because it forces you to think about each message you forward, because the instance is of a known class, rather than a new class, and because it doesn’t force you to accept all the methods of the super class: you can provide only the methods that really make sense. On the other hand, it makes you write more code, and it is harder to re-use (because it is not a subclass).

What Are The Different Identifier States Of A Thread?

The different identifiers of a Thread are: R - Running or runnable thread, S - Suspended thread, CW - Thread waiting on a condition variable, MW - Thread waiting on a monitor lock, MS - Thread suspended waiting on a monitor lock.

What Is Garbage Collection? What Is The Process That Is Responsible For Doing That In Java?

Reclaiming the unused memory by the invalid objects. Garbage collector is responsible for this process.

What Kind Of Thread Is The Garbage Collector Thread?

It is a daemon thread.

What Is A Daemon Thread?

These are the threads which can run without user intervention. The JVM can exit when there are daemon thread by killing them abruptly.

How Will You Invoke Any External Process In Java?

Runtime.getRuntime().exec(….)
Kaspersky Lab Most Frequently Asked Core Java Interview Questions Answers
Kaspersky Lab Most Frequently Asked Core Java Interview Questions Answers

What Is The Finalize Method Do?

Before the invalid objects get garbage collected, the JVM give the user a chance to clean up some resources before it got garbage collected.

What Is Mutable Object And Immutable Object?

If a object value is changeable then we can call it as Mutable object. (Ex., StringBuffer, …) If you are not allowed to change the value of an object, it is immutable object. (Ex., String, Integer, Float, …)

What Is The Basic Difference Between String And Stringbuffer Object?

String is an immutable object. StringBuffer is a mutable object.

What Is The Purpose Of Void Class?

The Void class is an uninstantiable placeholder class to hold a reference to the Class object representing the primitive Java type void.

What Is Reflection?

Reflection allows programmatic access to information about the fields, methods and constructors of loaded classes, and the use reflected fields, methods, and constructors to operate on their underlying counterparts on objects, within security restrictions.

What Is The Base Class For Error And Exception?

Throwable

What Is The Implementation Of Destroy Method In Java.. Is It Native Or Java Code?

This method is not implemented.

What Are The Approaches That You Will Follow For Making A Program Very Efficient?

By avoiding too much of static methods avoiding the excessive and unnecessary use of synchronized methods Selection of related classes based on the application (meaning synchronized classes for multiuser and non-synchronized classes for single user) Usage of appropriate design patterns Using cache methodologies for remote invocations Avoiding creation of variables within a loop and lot more.

What Is A Databasemetadata?

Comprehensive information about the database as a whole.

What Is Locale?

A Locale object represents a specific geographical, political, or cultural region.

How Will You Load A Specific Locale?

Using ResourceBundle.getBundle(…);

What Is Jit And Its Use?

Really, just a very fast compiler… In this incarnation, pretty much a one-pass compiler — no offline computations. So you can’t look at the whole method, rank the expressions according to which ones are re-used the most, and then generate code. In theory terms, it’s an on-line problem.

Is Jvm A Compiler Or An Interpreter?

Interpreter

What Is The Purpose Of Assert Keyword Used In Jdk1.4.x?

In order to validate certain expressions. It effectively replaces the if block and automatically throws the AssertionError on failure. This keyword should be used for the critical arguments. Meaning, without that the method does nothing.

How Will You Get The Platform Dependent Values Like Line Separator, Path Separator, Etc., ?

Using Sytem.getProperty(…) (line.separator, path.separator, …)

Is "abc" A Primitive Value?

The String literal “abc” is not a primitive value. It is a String object.

What Is Singleton?

It is one of the design pattern. This falls in the creational pattern of the design pattern. There will be only one instance for that entire JVM. You can achieve this by having the private constructor in the class. For eg., public class Singleton { private static final Singleton s = new Singleton(); private Singleton() { } public static Singleton getInstance() { return s; } // all non static methods … }

Subscribe to get more Posts :