My Hindi Forum

Go Back   My Hindi Forum > New India > Young World
Home Rules Facebook Register FAQ Community

Reply
 
Thread Tools Display Modes
Old 23-12-2009, 06:07 AM   #11
masterstroke
Member
 
masterstroke's Avatar
 
Join Date: Dec 2009
Posts: 33
Rep Power: 0
masterstroke is on a distinguished road
Smile What do you understand by numeric promotion?

The Numeric promotion is the conversion of a smaller numeric type to a larger numeric type, so that integral 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.
masterstroke is offline   Reply With Quote
Old 23-12-2009, 06:08 AM   #12
masterstroke
Member
 
masterstroke's Avatar
 
Join Date: Dec 2009
Posts: 33
Rep Power: 0
masterstroke is on a distinguished road
Smile What do you understand by casting in java language? What are the types of casting?

The process of converting one data type to another is called Casting. There are two types of casting in Java; these are implicit casting and explicit casting.

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 work for all scenarios.

Example

int i = 1000;

long j = i; //Implicit casting


Explicit casting in the process in which the complier are specifically informed to about transforming the object.

Example

long i = 700.20;

int j = (int) i; //Explicit casting
masterstroke is offline   Reply With Quote
Old 23-12-2009, 06:09 AM   #13
masterstroke
Member
 
masterstroke's Avatar
 
Join Date: Dec 2009
Posts: 33
Rep Power: 0
masterstroke is on a distinguished road
Post How can one prove that the array is not null but empty?

Print array.length. It will print 0. That means it is empty. But if it would have been null then it would have thrown a NullPointerException on attempting to print array.length.
masterstroke is offline   Reply With Quote
Old 23-12-2009, 06:11 AM   #14
masterstroke
Member
 
masterstroke's Avatar
 
Join Date: Dec 2009
Posts: 33
Rep Power: 0
masterstroke is on a distinguished road
Post Can I have multiple main methods in the same class?

We can have multiple overloaded main methods but there can be only one main method with the following signature :

Code:
public static void main(String[] args) {}
No the program fails to compile. The compiler says that the main method is already defined in the class.
masterstroke is offline   Reply With Quote
Old 23-12-2009, 06:11 AM   #15
masterstroke
Member
 
masterstroke's Avatar
 
Join Date: Dec 2009
Posts: 33
Rep Power: 0
masterstroke is on a distinguished road
Smile Explain working of Java Virtual Machine (JVM)?

JVM is an abstract computing machine like any other real computing machine which first converts .java file into .class file by using Compiler (.class is nothing but byte code file.) and Interpreter reads byte codes.
masterstroke is offline   Reply With Quote
Old 23-12-2009, 06:12 AM   #16
masterstroke
Member
 
masterstroke's Avatar
 
Join Date: Dec 2009
Posts: 33
Rep Power: 0
masterstroke is on a distinguished road
Post How can I swap two variables without using a third variable?

Add two variables and assign the value into First variable. Subtract the Second value with the result Value. and assign to Second variable. Subtract the Result of First Variable With Result of Second Variable and Assign to First Variable. Example:

Code:
int a=5,b=10;a=a+b; b=a-b; a=a-b;
An other approach to the same question

You use an XOR swap.

for example:

Code:
int a = 5; int b = 10;
a = a ^ b;
b = a ^ b;
a = a ^ b;
masterstroke is offline   Reply With Quote
Old 23-12-2009, 06:13 AM   #17
masterstroke
Member
 
masterstroke's Avatar
 
Join Date: Dec 2009
Posts: 33
Rep Power: 0
masterstroke is on a distinguished road
Smile What is data encapsulation?

Encapsulation may be used by creating ‘get’ and ’set’ methods in a class (JAVABEAN) which are used to access the fields of the object. Typically the fields are made private while the get and set methods are public. Encapsulation can be used to validate the data that is to be stored, to do calculations on data that is stored in a field or fields, or for use in introspection (often the case when using javabeans in Struts, for instance). Wrapping of data and function into a single unit is called as data encapsulation. Encapsulation is nothing but wrapping up the data and associated methods into a single unit in such a way that data can be accessed with the help of associated methods. Encapsulation provides data security. It is nothing but data hiding.
masterstroke is offline   Reply With Quote
Old 23-12-2009, 06:14 AM   #18
masterstroke
Member
 
masterstroke's Avatar
 
Join Date: Dec 2009
Posts: 33
Rep Power: 0
masterstroke is on a distinguished road
Post What is reflection API? How are they implemented?

Reflection is the process of introspecting the features and state of a class at runtime and dynamically manipulate at run time. This is supported using Reflection API with built-in classes like Class, Method, Fields, Constructors etc. Example: Using Java Reflection API we can get the class name, by using the getName method.
masterstroke is offline   Reply With Quote
Old 23-12-2009, 06:14 AM   #19
masterstroke
Member
 
masterstroke's Avatar
 
Join Date: Dec 2009
Posts: 33
Rep Power: 0
masterstroke is on a distinguished road
Post Does JVM maintain a cache by itself?

Does JVM maintain a cache by itself? Does the JVM allocate objects in heap? Is this the OS heap or the heap maintained by the JVM? Why

Yes, the JVM maintains a cache by itself. It creates the Objects on the HEAP, but references to those objects are on the STACK.
masterstroke is offline   Reply With Quote
Old 23-12-2009, 06:15 AM   #20
masterstroke
Member
 
masterstroke's Avatar
 
Join Date: Dec 2009
Posts: 33
Rep Power: 0
masterstroke is on a distinguished road
Smile What is difference between String and StringTokenizer?

A StringTokenizer is utility class used to break up string.

Example:

Code:
StringTokenizer str = new StringTokenizer(”Hello World”);

while (str.hasMoreTokens()) {

System.out.println(str.nextToken());

}
Output:

Hello

World
masterstroke is offline   Reply With Quote
Reply

Bookmarks

Tags
java interview question


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT +5. The time now is 05:49 PM.


Powered by: vBulletin
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
MyHindiForum.com is not responsible for the views and opinion of the posters. The posters and only posters shall be liable for any copyright infringement.