EXL Service Frequently Asked Core Java Interview Questions

What Is The Difference Between Notify And Notifyall Method?

notify wakes up a single thread that is waiting for object's monitor. If any threads are waiting on this object, one of them is chosen to be awakened. The choice is arbitrary and occurs at the discretion of the implementation. notifyAll Wakes up all threads that are waiting on this object's monitor. A thread waits on an object's monitor by calling one of the wait methods.

What Are Different Type Of Exceptions In Java?

There are two types of exceptions in java. Checked exceptions and Unchecked exceptions. Any exception that is is derived from Throwable and Exception is called checked exception except RuntimeException and its sub classes. The compiler will check whether the exception is caught or not at compile time. We need to catch the checked exception or declare in the throws clause. Any exception that is derived from Error and Runtime Exception is called unchecked exception. We don't need to explicitly catch a unchecked exception.

Explain About The Select Method With An Example?

Select part is useful in selecting text or part of the text. Arguments specified for the select command are the same as applicable to substring. First index is usually represents the start of the index. End of line makers are counted as one character. Example t.select (10,15) .

Can There Be An Abstract Class With No Abstract Methods In It?

Yes.

Can We Define Private And Protected Modifiers For Variables In Interfaces?

No.

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.

Can There Be An Abstract Class With No Abstract Methods In It?

Yes.
EXL Service Most Frequently Asked Core Java Interview Questions Answers
EXL Service Most Frequently Asked Core Java Interview Questions Answers

Can An Interface Have An Inner Class?

Yes.

public interface abc {
static int i=0;
void dd();
class a1 {
a1() {
int j;
System.out.println("in interfia");
};
public static void main(String a1[]) {
System.out.println("in interfia"); } } }

What Is User Defined Exception?

Apart from the exceptions already defined in Java package libraries, user can define his own exception classes by extending Exception class.

What Is The Difference Between Logical Data Independence And Physical Data Independence?

Logical Data Independence - meaning immunity of external schemas to changed in conceptual schema.

Physical Data Independence - meaning immunity of conceptual schema to changes in the internal schema.

What Are The Practical Benefits, If Any, Of Importing A Specific Class Rather Than An Entire Package (e.g. Import Java.net.* Versus Import Java.net.socket)?

It makes no difference in the generated class files since only the classes that are actually used are referenced by the generated class file. There is another practical benefit to importing single classes, and this arises when two (or more) packages have classes with the same name. Take java.util.Timer and javax.swing.Timer, for example. If I import java.util.* and javax.swing.* and then try to use "Timer", I get an error while compiling (the class name is ambiguous between both packages). Let’s say what you really wanted was the javax.swing.Timer class, and the only classes you plan on using in java.util are Collection and HashMap. In this case, some people will prefer to import java.util.Collection and import java.util.HashMap instead of importing java.util.*. This will now allow them to use Timer, Collection, HashMap, and other javax.swing classes without using fully qualified class names in.

How Many Methods Do U Implement If Implement The Serializable Interface?

The Serializable interface is just a "marker" interface, with no methods of its own to implement. Other ’marker’ interfaces are
java.rmi.Remote
java.util.EventListener

What Does The "abstract" Keyword Mean In Front Of A Method? A Class?

Abstract keyword declares either a method or a class. If a method has a abstract keyword in front of it,it is called abstract method.Abstract method has no body.It has only arguments and return type.Abstract methods act as placeholder methods that are implemented in the subclasses.

Abstract classes can’t be instantiated.If a class is declared as abstract,no objects of that class can be created.If a class contains any abstract method it must be declared as abstract.

You Can Create A String Object As String Str = "abc"; Why Cant A Button Object Be Created As Button Bt = "abc";? Explain

The main reason you cannot create a button by Button bt= "abc"; is because "abc" is a literal string (something slightly different than a String object, by-the-way) and bt is a Button object. The only object in Java that can be assigned a literal String is java.lang.String. Important to note that you are NOT calling a java.lang.String constuctor when you type String s = "abc";

Can Rmi And Corba Based Applications Interact ?

Yes they can. RMI is available with IIOP as the transport protocol instead of JRMP.

What Is Passed By Reference And Pass By Value ?

All Java method arguments are passed by value. However, Java does manipulate objects by reference, and all object variables themselves are references.

What Is A "stateless" Protocol ?

Without getting into lengthy debates, it is generally accepted that protocols like HTTP are stateless i.e. there is no retention of state between a transaction which is a single request response combination.

Difference Between A Class And An Object ?

A class is a definition or prototype whereas an object is an instance or living representation of the prototype.

Post a Comment

Previous Post Next Post