Interview Questions and Answers - Order By Newest Very Frequently asked. Usually asked along with String Class related questions. Ans. Class using which only immutable (objects that cannot be changed after initialization) objects can be created. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   oops   immutable  immutability   immutable  immutability class   string class   basic interview question Asked in 18 Companies Basic   frequent Try 2 Question(s) TestVery frequently asked in phone and walk in interviews. Q32. What are Marker Interfaces ? Name few Java marker interfaces ? Core Java
Ans. An interface without any method declaration is called as marker interface. there are 3 in-built interfaces in JVM i.e. serializable, clonable, remote Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   oops   interfaces   marker interface   serializable   clonable Asked in 21 Companies intermediate   frequent Try 1 Question(s) TestVery frequently asked. Usually difference between String,StringBuffer and StringBuilder is asked in different variations. Q33. Difference between StringBuffer and StringBuilder ? Core Java
Ans. StringBuffer is synchronized whereas StringBuilder is not. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   string   stringbuffer   string class   stringbuilder   synchronized   basic interview question   infosys technologies Asked in 17 Companies basic   frequent Try 1 Question(s) Test Q34. What is reflection ?
Ans. It is the process of examining / modifying the behaviour of an object at runtime. Sample Code for reflection Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   reflection   reflection api   ebay   mindtree Asked in 29 Companies basic   frequent Q35. Difference between jar , war and ear ? Java EE
Ans. Jar is Java Archieve i.e compressed Class or Class / Java files.
War comprises of compressed Servlet class files,JSP FIles,supporting files, GIF and HTML files.
Ear comprise of compressed Java and web module files ( was files ). Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   j2ee   jar   web development   war   ear   build management   release management Asked in 12 Companies basic   frequent Q36. 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) TestFrequently asked in CTS ( Based on 2 feedback ) Q37. 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 Q38. 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 Q39. How is Abstraction implemented in Java ? Core Java
Ans. Abstraction is provided in Java by following ways -
Coding to the ( Interfaces / Abstract Classes ) or contracts
By Encapsulating details within classes and exposing the minimal Door ( few public methods ) Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   oops concepts   abstraction   interfaces   abstract class   encapsulation  object oriented programming (oops)  oops concepts Asked in 3 Companies basic   frequent Q40. What are some different logging levels for log4j ? Log4j
Ans. DEBUG
ERROR
ALL
WARN
INFO
FATAL
OFF
TRACE
TRACE_INT
WARN Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   log4j   log4j level   logging   error logging Asked in 10 Companies Q41. How are values passed in Java ? By value or reference ? Core Java
Ans. Java only provides pass by value. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  ebay   pass by value   pass by reference   method call   methods   functions   function call Asked in 10 Companies basic   frequent Q42. What is a self Join and give an example of a self Join ?
or
What is self Join and What is it's purpose ? Database
Ans. When a Table Join itself , it's a Self Join. For example - we like to know the pair of department names where first dept has lesser employees than the later.
Select D1.name , D2.name from Dept D1, Dept D2 where D1.employee_count < D2.employee_count Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  sql  joins  self join  self-join  Pair of employee names with first having lesser salary than later  Pair of department names where first dept has lesser employees than the later Asked in 26 Companies basic   frequent Q43. What is database Normalization ? Database
Ans. https://en.wikipedia.org/wiki/Database_normalization Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  normalization  database Asked in 35 Companies intermediate   frequent Q44. What is the difference between authentication and authorization ? Authentication
Ans. Authentication is the process of verifying the identity and credentials of the user to authenticate him into the system.
whereas
Authorization is the process by which access to a segment , method or resource is determined.
Authorization is usually a step next to authentication. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  authentication  authorization  authentication vs authorization Asked in 9 Companies basic   frequent Ans. Amazon Simple Storage Service or S3 is object storage with a simple web service interface to store and retrieve any amount of data from anywhere on the web. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  aws  amazon s3  aws s3  aws storage  amazon cloud storage  amazon s3 Asked in 12 Companies Q46. How can we ensure thread safety in static method ? Core Java
Ans. By using synchronized static method or synchronized block Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  threads  synchronization  static methods Asked in 2 Companies intermediate Q47. What is abstraction ? Design
Ans. Abstraction is a process of hiding the implementation details and describing only the functionality to the user. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  bstraction  oops concepts  oops principle Asked in 22 Companies Ans. == compares values === is used in scripting languages for comparing two values as well as there data tpe. like in js,php. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  ==  ===  == vs === Asked in 13 Companies basic   frequent Q49. What are the types of authentication used in Web services ? Web Service
Ans. Encrypted User Name / Password
Encrypted Password within Cookie
Encrypted Tokens
IP
Client Certificates
Oauth Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  authentication  security  web service Asked in 12 Companies basic   frequent Frequently asked. Ans. Iterator is an interface that provides methods to iterate over any Collection. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   collections   iterator Asked in 11 Companies basic   frequent Q51. What are transient variables in java? Core Java
Ans. Transient variables are variable that cannot be serialized. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   serialization   transient Asked in 15 Companies intermediate   rare Q52. What is the use of HashCode in objects ? Core Java
Ans. Hashcode is used for bucketing in Hash implementations like HashMap, HashTable, HashSet etc. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   string   hashcode   hash code   string comparison  hashtable Asked in 17 Companies basic   frequent Q53. What are different types of second level cache ? Hibernate
Ans. 1. EHCache ( Easy Hibernate )
2. OSCache ( Open Symphony )
3. Swarm Cache ( JBoss )
4. Tree Cache ( JBoss ) Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  hibernate   orm   hibernate cache   technical lead Asked in 7 Companies Q54. What is Criteria in Hibernate ? Hibernate
Ans. Criteria is a simplified API for retrieving entities by composing Criterion objects.
For example - session.createCriteria(Employee.class).add( Restrictions.like("name", "A%") ).list();
will return all employee objects having name starting with A. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  hibernate   hibernate criteria Asked in 7 Companies Basic   Frequent Try 1 Question(s) Test Q55. Which Software Development methodology is being used in your current Job ? General
Ans. We are using Agile methodology. I attend daily stand up where the development leads takes the status of assigned stories, achievements, any bottlenecks or challenges. We follow iteration of 2 weeks. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  sdlc   agile methodology   software system analyst   software developer interview   development lead   project lead interview Asked in 14 Companies   frequent Q56. Which of the collections allows null as the key ?
a. HashTable
b. HashMap
c. TreeMap
d. LinkedHashMap Core Java
Ans. HashMap Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   collections   map  hashtable Asked in 2 Companies basic   frequent Must know at all levels. Among Top 10 frequently asked questions in Java. Very frequently asked to fresh graduates or less experienced professionals. Ans. Its a facility for code reuse and independent extension wherein a derived class inherits the properties of parent class. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  inheritance  object oriented programming (oops)  oops concepts  oops concepts  java concepts  code reuse  code re-use   classes  derived classes Asked in 14 Companies basic   frequent Very frequently asked to fresh graduates. Frequently asked in NSEiT and Accenture India Q58. Write a program to Generate prime numbers till a given number Core Java
Ans. public class Main {
public static void main(String args[]) {
int number = 2;
int count = 0;
long sum = 0;
int givenNumber = 1000;
while (count < givenNumber) {
if (isPrimeNumber(number)) {
sum = number;
count;
}
number;
}
System.out.println(sum);
}
private static boolean isPrimeNumber(int number) {
for (int i = 2; i <= number / 2; i) {
if (number % i == 0) {
return false;
}
}
return true;
}
} Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  generate prime numbers  code  coding Asked in 5 Companies basic   frequent Q59. What are the benefits of Enums ? Core Java
Ans. Enums in Java are used to declare predefined objects and then reuse them. they offer many benefits
1. Enum instance are type safe and thread safe.
2. Enum instances are singleton and hence reused.
3. If we use Enums with Switch , It makes sure that the passed argument is either of its instance and hence provides a safeguard.
4. If we use Enum with Sorted Collections we can sort the elements with a predefined priorities ( as per constant declaration in enum )
5. We can use Enum as a Factory by defining its constructor.
6. We can store related constant data within enum. For example - If we know the values for the map upfront, we can alternatively use an enum. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 6 Companies Q60. Difference between JDBC and Hibernate ? Database
Ans. JDBC is a standard Java Api for Database communication whereas Hibernate is an ORM framework that uses JDBC to connect with Database.
Hibernate is another layer of object table mapping over JDBC that provide a database independent, object oriented and an efficient way of database communication. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  JDBC  Hibernate  JDBC vs Hibernate Asked in 3 Companies