Tuesday, October 25, 2011

Java - Interview Questions


Interview Question links :

Spring : http://www.javabeat.net/articles/103-spring-framework-interview-questions-1.html


Java Interview Questions : http://www.allapplabs.com/interview_questions/java_interview_questions.htm#q1
http://www.techinterviews.com/master-list-of-java-interview-questions

MySQL Interview Questions : 
http://www.techinterviews.com/29-mysql-interview-questions
http://www.techinterviews.com/31-more-mysql-questions


Interface - Interface is a signature. You need to implement the methods in interface.

Abstract class - Abstract class can have abstract methods and normal private, protected methods. You need to extend the abstract class. You can use the super class methods. Abstract methods needs to implement.

class - blueprint of object

package - is a collection of classes with the given namespace

Inheritance - b is a child of a (ISA) child can inherit all the method from parent. You need to use extend

passbyreference : passing the address  passbyvalue : passing the value

synchronization in respect to multithreading - synchronization is the capability to control the access of multiple threads to shared resources. Without synchonization, it is possible for one thread to modify a shared variable while another thread is in the process of using or updating same shared variable.

Multithreading : If there is a for loop iterator 1 thread can loop it and another thread can add it to the loop

HashMap and Map - Map is Interface and Hashmap is class that implements that. HashMap (can store keys and values). HashMap will allow nulls as keys and values. Having said it doesn't allow duplicate values.

TreeMap : Treemap will have mutiple maps with parent and child maps. TreeMap is implemented based on SortedMap interface. Its slower than HashMap. The value stored like a tree. In whatever way the value stored the same way from Map you can retreive. HashMap the values will not be stored as we saved.

final - A final class can't be extended ie., final class may not be subclassed. A final method can't be overridden when its class is inherited. You can't change value of a final variable (is a constant)

Dispatcher servlet - It will delegate the request comes from web

HashMap and HashTable - HashMap is unsynchronized. Hashmap allows null in keys and values. Hashtable is syncrhonized. Synchronized is overhead unless its needed. If needed you can explicitly mention synchronized { }

Vector and ArrayList - ArrayList is unsynchronized. Arraylist is a class. You can add list of data. Vector is a synchronized.

Set - Set is also a collection. You can have group of objects / data which can be unique.

Collection - collection is a framework

Swing and Awt - AWT (Abstract window toolkit)  are heavy-weight componenets. Swings are light-weight components. Hence swing works faster than AWT.

equals and hashcode - is to compare to objects. IF there were 2 objects in same name to compare the object. In which object the names to compare you can mention in equals and compare

static class loading - new classname { dynamic class loading - class.ForName

Marker interface - no methods its used for clonable

Comparator compare(a,b) and Comparable a.compareTo(b) - Both interfaces.

immutable - The normal way we write string is immutable. a= "test" and a = "gubs". To object getting instantiate and reference getting change. StringBuffer is a mutable. When we assign the data it change the value in the same variable without instantiate.

Threads - Extended thread class, implement the runnable interface

Casting  - convert the type of the data

Design pattern  - ? singleton - ? how it works

Thread - ? how it works and examples ?

spring framework - how it works with example

hibernate - what is hibernate ? namedsqlquery ? update ? merge ?

Enhanced For loop - for (Object a : as) {} iterator for loop. Old style for loop

Get int / short value from String - parseInt or parseShort Short.parseShort(String); Integer.parseInt(String) Or Short.valueOf(String)

Convert short value to int value : new Integer(shortVal);

JAR File - Java Archive Files (It contains all the JAVA Classes for the specific module)

log4j properties load run time
-Dlog4j.configuration=file:/path/log4j.properties

WAR File - Web Application Archive (Contains all the JARs, JSP (JavaServer Page), Java Servlets, JAVA Classes , XML files, tag libraries and static Web pages (HTML and related files) that together constitute a Web application.


  • ArrayList: Take the data and pass it to the calling method, ignore duplicates and nulls.
  • HashSet: Take the data and pass it to the calling method, ignore the sequence, but make sure there are no duplicates.
  • LinkedHashSet: Take the data and pass it to the calling method, maintain the sequence and avoid duplicates.

1 comment :

Unknown said...

Hi

I read this post two times.

I like it so much, please try to keep posting.

Let me introduce other material that may be good for our community.

Source: Airline pilot interview questions

Best regards
Henry

// Below script tag for SyntaxHighLighter