| Other Core Java Interview Questions |
| |
| Question | Asked @ | Answers |
| |
| 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 |
| what do you meant by Platform-Independent? | Persistent | 4 |
| What is the difference between static and non-static
variables? | | 2 |
| What services that container provides? | | 1 |
| What is Map interface? | Wipro | 2 |
| Where the CardLayout is used? | | 1 |
| What are different types of Exceptions?. | | 5 |
| If you are reviewing the code of your team members, what
points will you look at, assuming the performance of the
application is not so great | KPIT | 2 |
| What is run-time class and system class? what is their
purpose? | | 1 |
| How to set the Heap size in Java ? | HCL | 2 |
| is java support call by reference and call by value, if
supports please explain? | | 3 |
| In the first round, there are 30 aptitude and 30 java
questions. We are suppose to finish both the papers within
60 minutes.
I cleared this round.
Next was test for programming skills.
In this section, Some 7 n's were asked.
1.
What is the difference b/w sleep(1000) and wait(1000)
2.
what is the diff b/w static block and static function?
3.
Write a program to validate IP address using string
tokenizer.
4.
Write a program to create singleton class
5.
write a function to reverse the string
6.
Write a prog to print prime nos upto n. EX: If n=9, It shld
print 1,2,3,5,7
7. One program on collections- Write a program to print no.
of times a number is repeating in an array.
EX- {1,3,1,2,5,7,3,7,34,3,8,3}
It should print: 1- 2 times
3- 4 times and so on
7. Write a func to print fibonocci series
After this I had technical interview, which went on for.
60 mins or so. There were qn's about multi threading,
Exception handling and collection classes.
Knowledge about collections was very important for the
post I was interviewed for. | Huawei | 1 |
| How to declare unique ArrayList ? | RMSI | 4 |
| How are this() and super() used with constructors? | | 4 |
| I have a Person object with 5 variables and I want to store
them in a file called Person.txt. What should I do? | KPIT | 3 |
| Explain pass by reference and pass by value? | Wipro | 5 |
| What is AppletStub? | | 1 |
| What is more advisable to create a thread, by implementing
a Runnable interface or by extending Thread class? | | 5 |
| Hi Friends, can you give difference between extending thread
class and implementing runnable interface. | | 2 |
| how can u create the object with out new operator | | 2 |
| |
| For more Core Java Interview Questions Click Here |