May 9, 2019

Srikaanth

CDW Core Java Interview Questions Answers

What Is Numeric Promotion?

Numeric promotion is the conversion of a smaller numeric type to a larger numeric type, so that integer and floating-point operations may take place. In numerical promotion, byte, char, and short values are converted to int values. The int values are also converted to long values, if necessary. The long and float values are converted to double values, as required.

What Is The Difference Between A Public And A Non-public Class?

A public class may be accessed outside of its package. A non-public class may not be accessed outside of its package.

To What Value Is A Variable Of The Boolean Type Automatically Initialized?

The default value of the boolean type is false

What Is The Difference Between The Prefix And Postfix Forms Of The ++ Operator?

The prefix form performs the increment operation and returns the value of the increment operation. The postfix form returns the current value all of the expression and then performs the increment operation on that value.

What Restrictions Are Placed On Method Overriding?

Overridden methods must have the same name, argument list, and return type. The overriding method may not limit the access of the method it overrides. The overriding method may not throw any exceptions that may not be thrown by the overridden method.

What Is A Java Package And How Is It Used?

A Java package is a naming context for classes and interfaces. A package is used to create a separate name space for groups of classes and interfaces. Packages are also used to organize related classes and interfaces into a single API unit and to control accessibility to these classes and interfaces.

What Modifiers May Be Used With A Top-level Class?

A top-level class may be public, abstract, or final.
CDW Most Frequently Asked Latest Core Java Interview Questions Answers
CDW Most Frequently Asked Latest Core Java Interview Questions Answers

What Is The Difference Between An If Statement And A Switch Statement?

The if statement is used to select among two alternatives. It uses a boolean expression to decide which alternative should be executed. The switch statement is used to select among multiple alternatives. It uses an int expression to determine which alternative should be executed.

Can A Method Be Overloaded Based On Different Return Type But Same Argument Type ?

No, because the methods can be called without using their return type in which case there is ambiquity for the compiler

What Happens To A Static Var That Is Defined Within A Method Of A Class ?

Can't do it. You'll get a compilation error

How Many Static Init Can You Have ?

As many as you want, but the static initializers and class variable initializers are executed in textual order and may not refer to class variables declared in the class whose declarations appear textually after the use, even though these class variables are in scope.

What Is The Difference Between Method Overriding And Overloading?

Overriding is a method with the same name and arguments as in a parent, whereas overloading is the same method name but different arguments

What Is Constructor Chaining And How Is It Achieved In Java ?

A child object constructor always first needs to construct its parent (which in turn calls its parent constructor.). In Java it is done via an implicit call to the no-args constructor as the first statement.

What Is The Difference Between The Boolean & Operator And The && Operator?

If an expression involving the Boolean & operator is evaluated, both operands are evaluated. Then the & operator is applied to the operand. When an expression involving the && operator is evaluated, the first operand is evaluated. If the first operand returns a value of true then the second operand is evaluated. The && operator is then applied to the first and second operands. If the first operand evaluates to false, the evaluation of the second operand is skipped.

Which Java Operator Is Right Associative?

The = operator is right associative.

Can A Double Value Be Cast To A Byte?

Yes, a double value can be cast to a byte.

What Is The Difference Between A Break Statement And A Continue Statement?

A break statement results in the termination of the statement to which it applies (switch, for, do, or while). A continue statement is used to end the current loop iteration and return control to the loop statement.

Can A For Statement Loop Indefinitely?

Yes, a for statement can loop indefinitely. For example, consider the following: for(;;) ;

To What Value Is A Variable Of The String Type Automatically Initialized?

The default value of an String type is null.

What Is The Difference Between A Field Variable And A Local Variable?

A field variable is a variable that is declared as a member of a class. A local variable is a variable that is declared local to a method.

How Are This() And Super() Used With Constructors?

this() is used to invoke a constructor of the same class. super() is used to invoke a superclass constructor.

What Does It Mean That A Class Or Member Is Final?

A final class cannot be inherited. A final method cannot be overridden in a subclass. A final field cannot be changed after it's initialized, and it must include an initializer statement where it's declared.

What Does It Mean That A Method Or Class Is Abstract?

An abstract class cannot be instantiated. Abstract methods may only be included in abstract classes. However, an abstract class is not required to have any abstract methods, though most of them do. Each subclass of an abstract class must override the abstract methods of its superclasses or it also should be declared abstract.

Can An Anonymous Class Be Declared As Implementing An Interface And Extending A Class?

An anonymous class may implement an interface or extend a superclass, but may not be declared to do both.

What Is The Catch Or Declare Rule For Method Declarations?

If a checked exception may be thrown within the body of a method, the method must either catch the exception or declare it in its throws clause.

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(….)

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.

https://mytecbooks.blogspot.com/2019/05/cdw-core-java-interview-questions.html
Subscribe to get more Posts :