Interview Questions and Answers - Order By Newest Usually asked to entry level software developers. Q61. Write a program to swap two variables without using third Core Java
Ans. public static void main(String[] args) {
int num1 = 1;
int num2 = 2;
num1 = num1^num2;
num2 = num1^num2;
num1 = num1^num2;
System.out.print("num1 = " + num1 +", num2 = "+num2);
} Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  code  coding Asked in 37 Companies basic   frequent Q62. If an Abstract class has only abstract methods, What's the difference between such a class and an interface ? Core Java
Ans. Such a class still can have member elements which can be inherited and hence facilitate code reuse. Moreover Abstract class can have non final static elements whereas interfaces are only allowed to have static final elements. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  abstract class   interfaces Asked in 2 Companies Basic Q63. What is JSON ? Json
Ans. JSON is "JavaScript Object Notation", primarily used for client-server or server-server communication. Its a much lighter and readable alternative to XML. JSON is language independent and is easily parse-able in all programming languages. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  json   markup language   client server communication Asked in 26 Companies basic   frequent Try 2 Question(s) Test Q64. What is an API ( Application Programming Interface ) ?
Ans. An API is a kind of technical contract which defines functionality that two parties must provide: a service provider (often called an implementation) and an application. an API simply defines services that a service provider (i.e., the implementation) makes available to applications. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  j2ee   api   java basic   frequent Ans. URL is Uniform Resource Locator which is representation of HTTP address. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  j2ee   http   internet   url basic   rare Ans. HTTP or Hypertext Transfer Protocol is internet protocol for tranmission of hypertext ( text with meta data ) over internet. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  j2ee   http   internet  fidelity Asked in 2 Companies basic   frequent Q67. Which access specifier can be used with Class ? Core Java
Ans. For top level class we can only use "public" and "default". We can use private with inner class. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   class   access specifier   inner classes basic   frequent Q68. Different ways of implementing Threads in Java ? Core Java
Ans. Threads in Java can be implement either by Extending Thread class or implementing runnable interface. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   threads   multi threading Asked in 1 Companies basic   frequent Ans. A Method that cannot be overriden in the sub class. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   oops   java keywords   final   final method   overriding   basic interview question basic   frequent Try 1 Question(s) TestVery Frequently asked.Favorite question in Walk in drive for many Indian service companies. Q70. What is a Final Class ?
Ans. A Class that cannot be sub classed. Sample Code for final class Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   oops   final   final class   java keyword   basic interview question Asked in 3 Companies basic   frequent Very frequently asked. Usually asked with questions related to String. Frequently asked at CTS / Cognizant Ans. Object that can't be changed after instantiation. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   oops   immutable  immutability Asked in 27 Companies basic   frequent Try 2 Question(s) TestAns. IndexOutofBoundException ,
NoClassDefFoundException ,
OutOfMemoryException ,
IllegalArgumentException,
NullPointerException,
IllegalStateException Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   oops   exceptions   basic interview question basic   frequent Q73. How can we make sure that a code segment gets executed even in case of uncatched exceptions ?
Ans. By putting it within finally. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   oops   exceptions   finally   uncatched exceptions basic   frequent Q74. What is "super" used for ?
Ans. Used to access members of the base class. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   oops   java keywords   super   basic interview question Asked in 2 Companies basic   frequent Q75. What is "this" keyword used for ?
Ans. Used to represent an instance of the class in which it appears. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   oops   java keywords   this   basic interview question basic   frequent Q76. Difference between boolean and Boolean ? Core Java
Ans. boolean is a primitive type whereas Boolean is a class. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   oops   wrapper classes   boolean vs Boolean basic   rare Q77. Difference between Serialization and Deserialization ? Core Java
Ans. Serialization is the process of writing the state of an object to a byte stream. Deserialization is the process of restoring these objects. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   oops   serialization   deserialization   serialization vs deserialization Asked in 2 Companies basic   frequent Try 1 Question(s) TestAns. An enum type is a special data type that enables for a variable to be a set of predefined constants Sample Code for enum Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   java5   enum   basic interview question basic   frequent Try 2 Question(s) TestAns. By static import , we can access the static members of a class directly without prefixing it with the class name. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   java5   static import   static   java keyword   static import Asked in 4 Companies basic   frequent Q80. Difference between Map and HashMap ? Core Java
Ans. Map is an interface where HashMap is the concrete class. Sample Code for map Sample Code for hashmap Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   collections   hashmap   map basic   frequent Frequently asked to fresh graduates. Q81. Is JVM, a compiler or interpretor ?
Ans. Its an interpretor. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   jvm   compiler   interpretor basic   frequent Q82. Is it necessary that each try block to be followed by catch block ? Core Java
Ans. It should be followed by either catch or finally block. Sample Code for Retry in case of exception Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   exceptions   exception handling   try   catch   finally  Oracle OCA Test Asked in 3 Companies basic   frequent Try 1 Question(s) Test Q83. Difference between nested and inner classes ?
Ans. Inner class is a type of nested class.
Inner classes are non static nested classes i.e the one that are associated with the instance of outer class. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   oops   static   nested classes   inner classes   nested vs inner class basic   frequent Try 1 Question(s) Test Q84. what is the difference between collections class vs collections interface ? Core Java
Ans. Collections class is a utility class having static methods for doing operations on objects of classes which implement the Collection interface. For example, Collections has methods for finding the max element in a Collection. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   collections   collections class   collection interface   basic interview question Asked in 6 Companies basic   frequent Try 1 Question(s) Test Q85. What is XML ? Xml
Ans. XML or eXtensible Markup Language is a markup languages for describing data and its metadata. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  xml   markup language basic   frequent Frequently asked in CTS ( Based on 2 feedback ) Q86. What is the difference between comparable and comparator in java.util pkg? Core Java
Ans. Comparable interface is used for single sequence sorting i.e.sorting the objects based on single data member where as comparator interface is used to sort the object based on multiple data members. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   java.util   comparable   comparator   collections Asked in 23 Companies basic   frequent Q87. Advantage of Collection classes over Arrays ? Core Java
Ans. Collections are re-sizable in nature. We can increase or decrease the size as per recruitment.
Collections can hold both homogeneous and heterogeneous data's.
Every collection follows some standard data structures.
Collection provides many useful built in methods for traversing,sorting and search. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   collections   collections classes   advantages of collections over arrays   collections vs arrays   basic interview question Asked in 6 Companies basic   frequent Q88. What is the difference between float and double?
Ans. Float can represent up to 7 digits accurately after decimal point, where as double can represent up to 15 digits accurately after decimal point. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   data types   float   double   difference between   basic interview question Q89. What are the features of encapsulation ? Core Java
Ans. Combine the data of our application and its manipulation at one place.
Encapsulation Allow the state of an object to be accessed and modified through behaviors.
Reduce the coupling of modules and increase the cohesion inside them. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   oops   oops concepts   encapsulation  object oriented programming (oops)  oops concepts   basic interview question Asked in 2 Companies basic   frequent Q90. Write a method to check if input String is Palindrome? Core Java
Ans. private static boolean isPalindrome(String str) {
if (str == null)
return false;
StringBuilder strBuilder = new StringBuilder(str);
strBuilder.reverse();
return strBuilder.toString().equals(str);
} Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   string   stringbuilder   stringbuilder   string class   code   palindrome Asked in 38 Companies Basic   frequent