Wednesday 14 August 2013

Top Most Java Language Interview Question and Answers

Java Language Interview Question and Answers,Java Language Interview Question and Answers,Java Language Interview Question and Answers,Java Language Interview Question and Answers,Java Language Interview Question and Answers,Java Language Interview Question and Answers,Java Language Interview Question and Answers,Java Language Interview Question and Answers,Java Language Interview Question and Answers,Java Language Interview Question and Answers,
Java Language Interview Question and Answers,Java Language Interview Question and Answers,Java Language Interview Question and Answers,Java Language Interview Question and Answers,
Java Language Interview Question and Answers,Java Language Interview Question and Answers,Java Language Interview Question and Answers,Java Language Interview Question and Answers

Java Language Interview Question and Answers:


1. What is an abstract class?

  Abstract class is a class which contain one or more abstract methods, which has to be implemented by sub classes. An abstract class can contain no abstract methods also i.e. abstract class may contain concrete methods.
2. what are class variables?

  Class variables are global to a class and belong to the entire set of objects that class creates. Only one memory location is created for each variable.3.
3. What is the Collection interface?

  The Collection interface provides support for the implementation of a mathematical bag - an unordered collection of objects that may contain duplicates.
4. What must a class do to implement an interface?

  The class must provide all of the methods in the interface and identify the interface in its implements clause.
5. What is the Collections API?

  The Collections API is a set of classes and interfaces that support operations on collections of objects.
6. What is an array?

  Array is a group of related data items that share a common name.For instance, we can define an array name salary to represent a set of salaries of a group of employees.
Examples : salary[10]
7. What is a list iterator?

  The List and Set collections provide iterators, which are objects that allow going over all the elements of a collection in sequence. The java.util.Iterator interface provides for one-way traversal and java.util.ListIterator is an iterator for lists that allows the programmer to traverse the list in either direction (i.e. forward and or backward) and modify the list during iteration.

8 What is the main difference between a String and a StringBuffer class?

  String is immutable : you can’t modify a string object but can replace it by creating a new instance. Creating a new instance is rather expensive.

StringBuffer is mutable : use StringBuffer or StringBuilder when you want to modify the contents. StringBuilder was added in Java 5 and it is identical in all respects to StringBuffer except that it is not synchronized,which makes it slightly faster at the cost of not being thread-safe.

9. When to use serialization?

  A common use of serialization is to use it to send an object over the network or if the state of an object needs to be persisted to a flat file or a database.

10. What is the main difference between shallow cloning and deep cloning of objects?

  Java supports shallow cloning of objects by default when a class implements the java.lang.Cloneable interface.
Deep cloning through serialization is faster to develop and easier to maintain but carries a performance overhead.

21. What are wrapper classes?

  primitive data types may be converted into object types by using the wrapper classes contained in the java.lang package.
Exampes : int, float, long, char, double

11. What is the difference between an instance variable and a static variable?

  Class variables are called static variables. There is only one occurrence of a class variable per JVM per class loader.When a class is loaded the class variables are initialized.
Instance variables are non-static and there is one occurrence of an instance variable in each class instance.Also known as a member variable or a field.

12 Where and how can you use a private constructor?

  Private constructor is used if you do not want other classes to instantiate the object and to prevent subclassing.The instantiation is done by a public static method (i.e. a static factory method) within the same class.

13. What is type casting?

  Type casting means treating a variable of one type as though it is another type.
Examples :
int m = 5;
byte n =i;

14. What is a user defined exception?

  User defined exceptions may be implemented by defining a new exception class by extending the Exception class.


15. What is an instanceof operator?

  Instanceof is an object reference operator and returns true if the object on the left-hand side is an instance of the glass given to the right hand side.This operator allows to determine whether the object belongs to a particular class or not.

16. What are runtime exceptions?

  Runtime exceptions are those exceptions that are thrown at runtime because of either wrong input data or because of wrong business logic etc. These are not checked by the compiler at compile time.


17 What is the difference between an interface and an abstract class?

  An abstract class may contain code in method bodies, which is not allowed in an interface. With abstract classes, you have to inherit your class from it and Java does not allow multiple inheritance. On the other hand, you can implement multiple interfaces in your class.

18. what is a package?

  A package is a namespace that organizes a set of related classes and interfaces.The classes contained in the packages of other programs can be easily reused.Packages, classes can be unique compared with classes in other packages.That is, two classes in two different packages can have the same name.


20. Why do threads block on I/O?

  Threads block on i/o (that is enters the waiting state) so that other threads may execute while the i/o Operation is performed.


21. What is the List interface?

  The List interface provides support for ordered collections of objects.


22. What is the Vector class?

  The Vector class provides the capability to implement a growable array of objects.

23 What is the base class of all classes?

  java.lang.Object

24 What is the importance of static variable?

  static variables are class level variables where all objects of the class refer to the same variable. If one object changes the value then the change gets reflected in all the objects.

25. What is the difference between a while statement and a do while statement?

  A while statement checks at the beginning of a loop to see whether the next loop iteration should occur. A do while statement checks at the end of a loop to see whether the next iteration of a loop should occur. The do whilestatement will always execute the body of a loop at least once.

LinkWithin

Related Posts Plugin for WordPress, Blogger...

Labels

Core Java programming core java interview question Core Java Faq's Servlets coding database jsp-servlet spring Java linux unix interview questions java investment bank Web Services Interview investment bank mysql Senior java developer interviews best practices java collection tutorial RMI SQL Eclipse FIX protocol tutorial tibco J2EE groovy java questions SCJP grails java 5 tutorial jdbc beginner error and exception Design Patterns Java Programming Tutorials fundamentals general object oriented programming xml Java Programs Hibernate Examples Flex JAMon Java xml tutorial logging Jsp Struts 2.0 Sybase and SQL Server debugging java interviews performance FIX Protocol interview questions JUnit testing WebSphere date and time tutorial experienced java IO tutorial java concurrency thread Ejb Freshers Papers IT Management Java Exapmle Java Script SQL and database tutorial examples Scwcd ant tutorials concurrency example and tutorial future state homework java changes java threading tricky Agile Business of IT Development JSTL Java JSON tutorial Java multithreading Tutorials PM Scrum data structure and algorithm java puzzles java tips testing tips windows 8 5 way to create Singleton Object Architect Interview Questions and Answers Architecture Architecure Bluetooth server as swing application that searches bluetooth device in 10 meter circle and show all devices. You can send file to any bluetooth device. C Programming CIO Callable Statement in Java Circular dependency of Objects in Java Comparable Example in Collection Custom annotation in Java Developer Interview Divide and rule example in java Drupal Example of Singleton Pattern FIX protocol ForkJoin Example in Java 7 Get data from dynamic table with Java Script Git HTML and JavaScript Health Hello World TCP Client Server Networking Program Hibernate Basics Hibernate Interview Question Answer J2EE Interview Question And Answers J2ME GUI Program JEE Interview QA JMS interview question Java J2EE Hibernate Spring Struts Interview Question Java System Property Java Threads Manager Portlets Provident Fund Read data from any file in same location and give the required result. Reading Properties File in Java Redpoint Rest WebService Client Rest Webservice Test SAL join with ven diagram SCP UNIX COMMAND SSL Singleton Pattern in Java Spring Bean Initialization methods and their order Spring Interview Questions Struts Struts 2.0 Basics Struts 2.0 Design Pattern Submit Html Form With Java Script On The Fly Unix executable For Java Program XOM DOM SAX XP books computers core java; core java; object oriented programming data structure; java investment bank; design pattern dtd duplicate rows in table get browser name with jquery grails podcast inner class java beginners tutorial java cache java networking tutorial java spring java util; java collections; java questions java.java1.5 linked list mailto function with all browser oracle database oracle duplicate rows orm schema social spring mvc questions struts transaction tricks tweet windows xslt