Interview Questions and Answers - Order By Rating Q61. Which Web and Application server is being used by your application ? Server
Ans. We are using Apache 2.3 and Tomcat 5.6 Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  web server  application server  server Basic   frequent Q62. how to access the methods of an inner class? Core Java
Ans. It depends on the type of inner class
To access non static inner class method
new OuterClass().new InnerClass().getMethod();
To access static method of static inner class
new OuterClass.InnerClass().getMethod(); Sample Code for inner class Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  inner classes  nested aclasses Asked in 1 Companies Intermediate   frequent Q63. Which elements of a class are ignored during serialization ? Core Java
Ans. 1. Objects are serialized and not classes and hence Static variables are ignored.
2. Transient is an explicit declaration to ignore the variable during serialization and hence transient instance variables are ignored too.
3. Base class instance variables if the base class hasn't been declared serializable. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  serialization Asked in 1 Companies intermediate   frequent Try 1 Question(s) Test Q64. Which environment variables do we need to set in order to run Java programs? Core Java
Ans. PATH, CLASSPATH and JAVA_HOME Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  environment variables  path  classpath  java_home Asked in 3 Companies basic   frequent Q65. Explain various Searching and Sorting Algorithms ? Algorithm
This question was recently asked at 'HeadStrong,ServiceNow'.This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  Search Algorithm  Sorting Algorithm Asked in 2 Companies basic   frequent Very frequently asked. Usually asked in this format or as difference with interfaces / concrete classes. Ans. Abstract class is the class that is not supposed to be instantiated. The purpose of the class to only have extension to the derived class. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  abstract class Asked in 6 Companies basic   frequent Q67. What is the use of static keyword in Java ? Core Java
Ans. static keyword is used to specify that the respective programming construct ( method , variable ) belongs to the class and not to its instance and is supposed to be shared by all instances of the class. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  static keyword Asked in 1 Companies basic   frequent Q68. What technical stuff you like to do in your free time ? General
Ans. [Open Ended Answer] Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 2 Companies   frequent Frequently asked in Cognizant ( Based on 2 feedback ) Q69. What are Inner , Outer , Left and Right Joins in SQL ? Database
Ans. Inner join is the intersection of two tables on the condition defined by the where clause i.e will get records from both tables matched by a column.
Outer join is the union of two tables i.e will get all records from both tables and will put null in the columns where related records are not present.
Left Outer join is the left union of two tables i.e all records from the table on the left and values from the right table for related records else null for the columns from right table.
Right Outer join is the right union of two tables i.e all records from the table on the right and values from the left table for related records else null for the columns from left table. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  sql  inner join  outer join  right join  left join Asked in 24 Companies basic   frequent Q70. What is an exception and exception handling in Java ? Core Java
Ans. An Exception in java is the occurrence during computation that is anomalous and is not expected.
Exception handling is the mechanism which is used to handle such situations.
Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  exception handling Asked in 18 Companies basic   frequent Q71. 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 Q72. Why java doesn't support multiple Inheritance ?
or
Explain Java Diamond Problem. Core Java
Ans. class A {
void test() {
System.out.println("test() method");
}
}
class B {
void test() {
System.out.println("test() method");
}
}
Suppose if Java allows multiple inheritance like this,
class C extends A, B {
}
A and B test() methods are inheriting to C class.
So which test() method C class will take? As A & B class test() methods are different , So here we would Facing Ambiguity. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  multiple inheritance  object oriented programming (oops)  oops concepts  diamond problem Asked in 20 Companies basic   frequent Q73. Which class is the root class of all Exceptions in Java ?
Ans. Throwable Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 1 Companies basic   frequent Q74. Name some of the Java Keywords ? Core Java
Ans. Static , Final , Synchronized, private , public , protected, volatile, transient, super, this,import , abstract,native,default (effective java 8), new Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java keywords   frequent Q75. Explain some of the features of Java ? Core Java
Ans. Object Oriented - Java is object oriented but isn't purely object oriented as we have primitives along with objects.
Platform Independent - As JVM provides the translation to the Machine code as per the underlying Operating System.
Interpreted as well as compiled - Java files are compiled as class files and then class files are interpreted by JVM.
Runs on a Virtual Machine - Which is JVM that acts as an independent sub environment.
Multi-threaded - As applications can run on single thread as well as multi thread.
Modularity - Through usage of Classes , methods and Interfaces.
Robust
Usage in variety of Application types - Web , Gaming, BigData. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve     frequent Q76. What do you look for when you do code review ? Core Java
Ans. Modularity - First sign of good code is whether it has been segregated into methods and classes appropriately. I dont mind it in excess because I believe that is forward looking strategy as applications tends to expand and eventually become hard to read.
Self Explanatory - Variables and methods should be named in a way that the code should be self explanatory even without comments. Use of Constant variables to explain use of literal.
Proper Code Reuse - If there is anything being reused , it should be moved to parent classes / methods.
Proper composition calls - Composed hierarchy should not be access in just single line. One or two levels is ok but having multiple levels make it hard to read and debug. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  code review  clean code Asked in 1 Companies intermediate   frequent Q77. What is Maven ? Maven
Ans. Maven is a build automation tool used primarily for Java projects. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  maven  build Asked in 6 Companies basic   frequent Q78. Explain some of the http status codes you know ? Java EE
Ans. 500 is Internal Server Error
404 is resource not found
400 is Bad Request
403 is Forbidden
401 is Unauthorized
200 is OK Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  http  http status codes Asked in 2 Companies   frequent Ans. Collections in java is a framework of classes that provides an abstracted data structure to store and manipulate the group of objects. Each class is unique in the way it stores , search , sort and modify the elements. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  collections  collection classes Asked in 1 Companies Basic   frequent Frequently asked in Accenture. Q80. What is your biggest achievement at work ? General
Ans. [Open Ended Answer] Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  general question  non technical question Asked in 20 Companies   frequent Q81. Difference between Error and Exception ? Core Java
Ans. An Error indicates serious problems that a reasonable application should not try to catch whereas
An Exception indicates conditions that a reasonable application might want to catch. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  error  exception handling  exceptions Asked in 2 Companies basic   frequent Q82. Difference between Array and ArrayList ? Core Java
Ans. <a href="http://javahungry.blogspot.com/2015/03/difference-between-array-and-arraylist-in-java-example.html" rel="nofollow">http://javahungry.blogspot.com/2015/03/difference-between-array-and-arraylist-in-java-example.html</a> Sample Code for ArrayList Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  array  arraylist Asked in 11 Companies basic   frequent Q83. What is a web service ? Java EE
Ans. A Web service is a service offered by one system to another, for communication over web through http. XML are JSON are usually used for sending across information from one system to another. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  web service Asked in 2 Companies basic   frequent Q84. Difference between relational databases and NoSQL databases ? Database
Ans. https://www.mongodb.com/scale/nosql-vs-relational-databases Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  database management  nosql database  relational database Asked in 1 Companies   frequent Frequently asked in high end product companies. Frequently asked in Deloitte. Q85. How is Hashmap internally implemented in Java ? Core Java
Ans. https://medium.com/javarevisited/internal-working-of-hashmap-in-java-97aeac3c7beb#:~:text=HashMap%20internally%20uses%20HashTable%20implementation,the%20entries%20into%20the%20map. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  hashmap  collections  hashmap internal implementation Asked in 20 Companies expert   frequent Very Frequently asked to Senior Software Engineers or Developers. Q86. Describe some of the Design Patterns you have used ? Design
Ans. [Open Ended Answer] Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  design patterns Asked in 17 Companies intermediate   frequent Frequently asked Generic Question. Q87. Why do you want to work for our company ? General
Ans. [Open Ended Answer]
Usually answered stating your keen interest in the role offered and challenges and opportunities the role offers. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 42 Companies   frequent Q88. Difference between Static and Singleton Class ? Core Java
Ans. 1. Static class is a class which cannot be instantiated and all its members are static whereas Singleton is the class that only permit creation of single object and then the object is reused.
2. As there is no object in Static class, it cannot participate in runtime Polymorphism.
3. As Static class doesnt allow creating objects and hence it cannot be serialized.
4. Static class body is initialized eagerly at application load time whereas Singleton object can be initiated eagerly using static blocks or lazily on first need.
5. Its not recommended to use pure static class as it fails to use many OOPs concepts. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  Static Class  Singleton  Static Class vs Singleton Asked in 3 Companies Intermediate   frequent Q89. Write a Program to check if 2 strings are Anagrams ? Core Java
Ans. public void checkIfAnagram(String str1,String str2){
boolean anagram = true;
for(char c:str1.toCharArray()){
if(!str2.contains(String.valueOf(c))){
System.out.println("Strings are Anagrams");
anagram = false;
}
if(anagram == true){
System.out.println("Strings are not Anagrams");
}
}
} Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   check if 2 strings are Anagrams Asked in 30 Companies basic   frequent Q90. Explain Agile Software Development Methodology ? Process
Ans. https://en.wikipedia.org/wiki/Agile_software_development Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  software development process  agile Asked in 5 Companies   frequent