Core Java Interview Questions Page 2, Core Java QuestionQ

This page discusses - Core Java Interview Questions Page 2, Core Java QuestionQ

Core Java Interview Questions Page 2, Core Java QuestionQ

Core Java Interview Questions -2

     

Question: What is the use of Object and Class Classes?
Answer: The Object class is the superclass of all other classes and it is highest-level class in the Java class hierarchy. Instances of the class Class represent classes and interfaces in a running Java application. Every array also belongs to a class that is reflected as a Class object that is shared by all arrays with the same element type and number of dimensions. The primitive Java types (boolean, byte, char, short, int, long, float, and double), and the keyword void are also represented as Class objects.

Question: Differentiate between a Class and an Object?
Answer:
A Class is only the definition or prototype of real life object. Whereas an object is an instance or living representation of real life object. Every object belongs to a class and every class contains one or more related objects.

Question: What do you understand by a variable?
Answer: The variables plays very important role in computer programming. Variables enable programmers to write flexible programs. It is a memory location that has been named so that it can be easily be referred in the program. The variable is used to hold the data and it can be changed changed during the course of the execution of the program.

Question: What do you understand by numeric promotion?
Answer: The 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 the numerical promotion process the 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 

Question: What do you understand by casting in java language?
Answer: The process of converting one datatype to another in Java language is called Casting.

Question: What are the types of casting?
Answer: There are two types of casting in Java, these are Implicit casting and explicit casting.

Question: What is Implicit casting?
Answer: Implicit casting is the process of simply assigning one entity to another without any transformation guidance to the compiler. This type of casting is not permitted in all kinds of transformations and may not workout for all application scenarios.

Example:

int i = 4000;

long h = i; //Implicit casting

Question: What is explicit casting?
Answer:
Explicit casting in the process in which the complier are specifically informed to about transforming the object.

long ln = 700.20;

t = (int) ln; //Explicit casting

Question: What do you understand by downcasting?
Answer: The process of Downcasting refers to the casting from a general to a more specific type, i.e. casting down the hierarchy

Question: What do you understand by downcasting?
Answer: The process of Downcasting refers to the casting from a general to a more specific type, i.e. casting down the hierarchy

Question: What do you understand by final value?
Answer: FINAL for a variable: value is constant. FINAL for a method: cannot be overridden. FINAL for a class: cannot be derived

.