Core Java 3
Home Up Core java Core Java 2 Everything Else Core Java 3 Java Network Unanswered Questions

 

Java Interview Questions

Visit Java Interview Homepage

<<< Previous Page

Q10. A note on defining floating point literal ?

A10. A floating point literal is defined as float g = 3576.2115F.

 

Q11. A note on arrays of object references?

A11. If the array type is CLASS then one can put objects of any subclass of the declared type into the array. The following example on sports explains the above concept :

class sports { }

class football extends sports { }

class hockey extends sports { }

class baseball extends sports { }

sports [ ] mysports = { new football (),

new hockey (),

new baseball ()};



 

Q12. What is meant by "instanceof" comparison?

A12. It is used for object reference variables only.You can use it to check wether an object is of a particular type.



 

Q13. when is amethod said to be overloaded?

A13. Two or more methods are defined within the same class that share the same name and their parameter declarations are different then the methods are said to be overloaded.



 

Q14. What is meant by Recursion?

A14. It is the process of defining something in terms of itself. Interms of JAVA it is the attribute that allows a method to call itself.The following example of calculating a factorial gives an example of recursion.

class Factorial {

int fact (int n) {

int result;

if (n= 1) return 1;

result = fact(n -1) * n;

return result;

}

}

class Recursion {

Public static void main (string args[ ]) {

Factorial f = new Factorial ();

system.out.println ("Factorial of 10 is " + f.fact(10));

}

}



 

Q15. A cool example to explain the concept of METHOD in JAVA.

A15. Let us say you are in Mcdonalds and you order for #7 for here with medium coke. The cashier takes your order and punches it on the computer. The folks in the kitchen get the order and they get the crispy chicken and pass it on to the guy who puts a medium fries and finally a medium coke is filled and the order is served to you. In other terms if all this was supposed to be done by a robot then it could have been programmed the following way.



 

void #7forherewithmediumcoke( )

{

Get (crispy chicken, lattice, butter, fries, coke);

make (sandwich);

fill (coke, fries);

}

<<< Previous Page

Search this site for:

 

Please use this form to communicate any issues/problems with this website or its contents. If you find any content inappropriate for any reason, please let me know. Hit Counter