| Other Core Java Interview Questions |
| |
| Question | Asked @ | Answers |
| |
| what is the output ? Math.floor(-2.1)
a)2
b)-2
c)-3.0
d)0 | Accenture | 2 |
| public class AboutStrings{
public static void main(String args[]){
String s1="hello";
String s2="hel";
String s3="lo";
String s4=s2+s3;
//to know the hash codes of s1,s4.
System.out.println(s1.hashCode());
System.out.println(s4.hashCode());
// these two s1 and s4 are having same hashcodes.
if(s1==s4){
System.out.println("s1 and s4 are same.");
}else
System.out.println("s1 and s4 are not same.");
}
}
Somebody told me that, == operator compares references of
the objects.
In the above example even though s1 and s4 are refering to
same object(having same hash codes),
it is printing s1 and s4 are not same.
Can anybody explain in detail why it is behaving like this?
Thanks in Advance
RavuriVinod
| TCS | 3 |
| why applet doesn't have main? isn't possible a program with
out main? | | 5 |
| transaction attributes ? | | 2 |
| Howmany address lines are required to addressing 1 MB
memory? | | 3 |
| How are commas used in the initialization and iteration
parts of a for statement? | | 2 |
| Explain the difference between scrollbar and scrollpane? | | 1 |
| Can an object?s finalize() method be invoked while it is
reachable? | | 2 |
| How to declare unique ArrayList ? | RMSI | 4 |
| 1).Is Object class abstract or not?
2).Is main method(public static void main(String args[])low
priority thread or high priority thread?
| TCS | 2 |
| What is meant by Java interpreter? | | 2 |
| What is the specification of ?CODEBASE? in an applet? | | 1 |
| Difference between array and arraylist. | Sai-Softech | 4 |
| what is polymorphism with example?types of polymorphism? | HP | 6 |
| Why do we use public static with the main function in Java? | Infosys | 7 |
| what is the purpose of class "Object" which is base class
for all classes? | | 3 |
| What is method Overriding in the perspective of OOPS? | | 2 |
| Can a double value be cast to a byte? | | 3 |
| Without creating a new object, How you can retrieve a
String or other object? | | 1 |
| what is the form of storage space in java? | | 5 |
| |
| For more Core Java Interview Questions Click Here |