| Forums.Sureshkumar.net : A Perfect Place to Share Knowledge Blogs Games Magazines |
|
|
#1 (permalink) |
|
Member
Join Date: Jun 2008
Age: 24
Posts: 72
Thanks: 2 Thanked 27 Times in 20 Posts Thanks: 2
Thanked 27 Times in 20 Posts
Blog Entries: 2
Rep Power: 3
|
Core Java Questions Interview Ques n Answers-II
Question: Does it matter in what order catch statements for FileNotFoundException and IOExceptipon are written?
Answer: Yes, it does. The FileNoFoundException is inherited from the IOException. Exception's subclasses have to be caught first. Question: Can an inner class declared inside of a method access local variables of this method? Answer: It's possible if these variables are final. Question: What can go wrong if you replace && with & in the following code: String a=null; if (a!=null && a.length()>10) {...} Answer:A single ampersand here would lead to a NullPointerException. Question: What's the main difference between a Vector and an ArrayList Answer: Java Vector class is internally synchronized and ArrayList is not. Question: When should the method invokeLater()be used? Answer: This method is used to ensure that Swing components are updated through the event-dispatching thread. Question: How can a subclass call a method or a constructor defined in a superclass? Answer: Use the following syntax: super.myMethod(); To call a constructor of the superclass, just write super(); in the first line of the subclass's constructor. For senior-level developers: Question: What's the difference between a queue and a stack? Answer: Stacks works by last-in-first-out rule (LIFO), while queues use the FIFO rule Question: You can create an abstract class that contains only abstract methods. On the other hand, you can create an interface that declares the same methods. So can you use abstract classes instead of interfaces? Answer: Sometimes. But your class may be a descendent of another class and in this case the interface is your only option. Question: What comes to mind when you hear about a young generation in Java? Answer: Garbage collection. Question: What comes to mind when someone mentions a shallow copy in Java? Answer: Object cloning. Question: If you're overriding the method equals() of an object, which other method you might also consider? Answer: hashCode() Question: You are planning to do an indexed search in a list of objects. Which of the two Java collections should you use: ArrayList or LinkedList? Answer: ArrayList Question: How would you make a copy of an entire Java object with its state? Answer: Have this class implement Cloneable interface and call its method clone(). Question: How can you minimize the need of garbage collection and make the memory use more effective? Answer: Use object pooling and weak object references. Question: There are two classes: A and B. The class B need to inform a class A when some important event has happened. What Java technique would you use to implement it? Answer: If these classes are threads I'd consider notify() or notifyAll(). For regular classes you can use the Observer interface. Question: What access level do you need to specify in the class declaration to ensure that only classes from the same directory can access it? Answer: You do not need to specify any access level, and Java will use a default package access level .
__________________
The early years were more about learning than about acting. I had to carry on my father’s work, which was a big challenge. Azim Premji |
|
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| JAVA WEB SITES | yathish | JAVA Technologies | 2 | 20-11-08 12:11 AM |
| tips for interview | ozobalu | HR Questions | 9 | 23-09-08 12:32 AM |
| Dug it | yathish | Companies Info & Recruitment Process | 4 | 10-09-08 06:25 PM |
| Interview Questions | Pink | Other Queries | 15 | 20-08-08 03:37 AM |