October 26, 2018

Srikaanth

Huawei Most Frequently Asked Latest Core Java Interview Questions Answers

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.

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"); } } }
Huawei Most Frequently Asked Latest Core Java Interview Questions Answers
Huawei Most Frequently Asked Latest Core Java Interview Questions Answers

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.

What Are The Four Corner Stones Of Oop?

Abstraction, Encapsulation, Polymorphism and Inheritance.

What Gives Java It's "write Once And Run Anywhere" Nature?

Java is compiled to be a byte code which is the intermediate language between source code and machine code. This byte code is not platorm specific and hence can be fed to any platform. After being fed to the JVM, which is specific to a particular operating system, the code platform specific machine code is generated thus making java platform independent.

How Can A Dead Thread Be Restarted?

A dead thread cannot be restarted.

What Happens If An Exception Is Not Caught?

An uncaught exception results in the uncaughtException() method of the thread’s ThreadGroup being invoked, which eventually results in the termination of the program in which it is thrown.

What Is A Compilation Unit?

A compilation unit is a Java source code file.

What Is A Task's Priority And How Is It Used In Scheduling?

A task’s priority is an integer value that identifies the relative order in which it should be executed with respect to other tasks. The scheduler attempts to schedule higher priority tasks before lower priority tasks.

What Value Does Readline() Return When It Has Reached The End Of A File?

The readLine() method returns null when it has reached the end of a file.

Can An Object's Finalize() Method Be Invoked While It Is Reachable?

An object’s finalize() method cannot be invoked by the garbage collector while the object is still reachable. However, an object’s finalize() method may be invoked by other objects.

Does Garbage Collection Guarantee That A Program Will Not Run Out Of Memory?

Garbage collection does not guarantee that a program will not run out of memory. It is possible for programs to use up memory resources faster than they are garbage collected. It is also possible for programs to create objects that are not subject to garbage collection.

Is Sizeof A Keyword?

The sizeof operator is not a keyword.

What State Does A Thread Enter When It Terminates Its Processing?

When a thread terminates its processing, it enters the dead state.

Can A Lock Be Acquired On A Class?

Yes, a lock can be acquired on a class. This lock is acquired on the class’s Class object.

How Are Observer And Observable Used?

Objects that subclass the Observable class maintain a list of observers. When an Observable object is updated it invokes the update() method of each of its observers to notify the observers that it has changed state. The Observer interface is implemented by objects that observe Observable objects.

What Is A Transient Variable?

transient variable is a variable that may not be serialized.

Subscribe to get more Posts :