Showing posts with label Core Java Interview Questions and Answers. Show all posts
Showing posts with label Core Java Interview Questions and Answers. Show all posts

Sunday, February 23, 2014

CORE JAVA INTERVIEW QUESTIONS AND ANSWERS

51. What is the purpose of finalization?
The purpose of finalization is to give an unreachable object the opportunity to perform any cleanup processing before the object is garbage collected.
52. Which class is the immediate superclass of the MenuComponent class.
Object
53. What invokes a thread's run() method?
After a thread is started, via its start() method or that of the Thread class, the JVM invokes the thread's run() method when the thread is initially executed.
54. What is the difference between the Boolean & operator and the && operator?
If an expression involving the Boolean & operator is evaluated, both operands are evaluated. Then the & operator is applied to the operand. When an expression involving the && operator is evaluated, the first operand is evaluated. If the first operand returns a value of true then the second operand is evaluated. The && operator is then applied to the first and second operands. If the first operand evaluates to false, the evaluation of the second operand is skipped.
55. Name three subclasses of the Component class.

CORE JAVA INTERVIEW QUESTIONS AND ANSWERS

41. What is the catch or declare rule for method declarations?
If a checked exception may be thrown within the body of a method, the method must either catch the exception or declare it in its throws clause.
42. What is the difference between a MenuItem and a CheckboxMenuItem?
The CheckboxMenuItem class extends the MenuItem class to support a menu item that may be checked or unchecked.
43. What is a task's priority and how is it used in scheduling?
A task's priority is an integer value that identifies the relative order in which it should be executed with respect to other tasks. The scheduler attempts to schedule higher priority tasks before lower priority tasks.
44. What class is the top of the AWT event hierarchy?
The java.awt.AWTEvent class is the highest-level class in the AWT event-class hierarchy.
45. When a thread is created and started, what is its initial state?
A thread is in the ready state after it has been created and started.
46. Can an anonymous class be declared as implementing an interface and extending a class?
An anonymous class may implement an interface or extend a superclass, but may not be declared to do both.
47. What is the range of the short type?

Friday, January 31, 2014

Core Java Interview Questions and Answers

Whether you are a fresher or highly experienced professional, core java plays a vital role in any Java/JEE interview. Core Java is the favorite area in most of the interviews and plays a crucial role in deciding the outcome of your interview.
I have already written a lot about java interview questions for specific topics such as String, Collections and Multithreading.
  1. Java String Interview Questions
  2. Java Thread Interview Questions
  3. Java Collections Interview Questions
  4. Java Exception Interview Questions
Here I am providing some of the important core java interview questions with answers that you should know. You can bookmark this post to brush up your knowledge before heading for an interview.
  1. What do you mean by platform independence of Java?
  2. What is JVM and is it platform independent?
  3. What is the difference between JDK and JVM?
  4. What is the difference between JVM and JRE?
  5. Which class is the superclass of all classes?
  6. Why Java doesn’t support multiple inheritance?
  7. Why Java is not pure Object Oriented language?
  8. What is difference between path and classpath variables?
  9. What is the importance of main method in Java?
  10. What is overloading and overriding in java?
  11. Can we overload main method?
  12. Can we have multiple public classes in a java source file?
  13. What is Java Package and which package is imported by default?
  14. What are access modifiers?
  15. What is final keyword?
  16. What is static keyword?
  17. What is finally and finalize in java?
  18. Can we declare a class as static?
  19. What is static import?
  20. What is try-with-resources in java?
  21. What is multi-catch block in java?
  22. What is static block?
  23. What is an interface?
  24. What is an abstract class?
  25. What is the difference between abstract class and interface?
  26. Can an interface implement or extend another interface?
  27. What is Marker interface?
  28. What are Wrapper classes?
  29. What is Enum in Java?
  30. What is Java Annotations?
  31. What is Java Reflection API? Why it’s so important to have?
  32. What is composition in java?
  33. What is the benefit of Composition over Inheritance?
  34. How to sort a collection of custom Objects in Java?
  35. What is inner class in java?
  36. What is anonymous inner class?
  37. What is Classloader in Java?
  38. What are different types of classloaders?
  39. What is ternary operator in java?
  40. What does super keyword do?
  41. What is break and continue statement?
  42. What is this keyword?
  43. What is default constructor?
  44. Can we have try without catch block?
  45. What is Garbage Collection?
  46. What is Serialization and Deserialization?
  47. How to run a JAR file through command prompt?
  48. What is the use of System class?
  49. What is instanceof keyword?
  50. Can we use String with switch case?

Tuesday, August 13, 2013

Core Java Interview Questions and Answers

  1. What is the difference between an if statement and a switch statement?
    The if statement is used to select among two alternatives. It uses a boolean expression to decide which alternative should be executed. The switch statement is used to select among multiple alternatives. It uses an int expression to determine which alternative should be executed.

  2. What are the practical benefits, if any, of importing a specific class rather than an entire package (e.g. import java.net.* versus import java.net.Socket)?
    It makes no difference in the generated class files since only the classes that are actually used are referenced by the generated class file. There is another practical benefit to importing single classes, and this arises when two (or more) packages have classes with the same name. Take java.util.Timer and javax.swing.Timer, for example. If I import java.util.* and javax.swing.* and then try to use "Timer", I get an error while compiling (the class name is ambiguous between both packages). Let's say what you really wanted was the javax.swing.Timer class, and the only classes you plan on using in java.util are Collection and HashMap. In this case, some people will prefer to import java.util.Collection and import java.util.HashMap instead of importing java.util.*. This will now allow them to use Timer, Collection, HashMap, and other javax.swing classes without using fully qualified class names in.

Monday, August 5, 2013

Core Java Interview Questions and Answers

  1. What is the most important feature of Java?
    Java is a platform independent language.

  2. What do you mean by platform independence?
    Platform independence means that we can write and compile the java code in one platform (eg Windows) and can execute the class in any other supported platform eg (Linux,Solaris,etc).

  3. Are JVM's platform independent?
    JVM's are not platform independent. JVM's are platform specific run time implementation provided by the vendor.