Interview Questions and Answers - Order By Newest Q2041. Is HttpServlet an abstract class ? Java EE
Ans. Yes Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 1 Companies Q2042. Why do we need ConcurrentHashMap ? Core Java
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   Q2043. What is the default size of ArrayList ? Core Java
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   Q2044. Find minimum operations required to convert one string to another. Allowed operation :Insertion Deletion Replace, all operational costs are same. Core Java
Ans. StringBuilder str = new StringBuilder("Pizza");
int size = str.length();
str = str.replace(size-1, size, "u");
System.out.println("After replace, str = " str); // prints Pizzu Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 1 Companies Q2045. Write code to read data from a file and write it to a file with 2 threads using the thread name content Core Java
This question was recently asked at 'verifone'.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  threads  file  file handling Asked in 1 Companies Q2046. How to Create Cron Job in Hybris e-commerce suite Hybris
This question was recently asked at 'Patni Computer Systems,IGate'.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   Asked in 2 Companies Q2047. What is the need for filters in Java Servlets ? Java EE
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   Q2048. What is the difference between Interfaces and Abstract Classes with respect to Java 8 ? Core Java
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   Q2049. Which of the OOP's feature - encapsulation or abstraction - is more important ? Core Java
Ans. Encapsulation facilitates security by hiding data and logic whereas Abstraction simplifies organization of data and related logic.
As applications scale, both concepts are required for easy management and maintenance. Encapsulation for security and criss cross communication between objects / modules will make it vulnerable. and Abstraction for better organization that enables better understanding of application code and easy maintainability. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  oops  oops features  oops concepts Q2050. Which of the polymorphism type - static or runtime - is more important ? Core Java
Ans. Method overloading / static polymorphism compared to method overriding / runtime polymorphism has very limited usage as it just opens up an alternate way of defining a different method with the same name.
Method Overriding on other hand opens up many other features like contracting , interfacing , pluging development and hence development of libraries and frameworks. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  oops  oops features  oops concepts Q2051. What is the reason that non-static method are not allowed to be referenced from a static context in Java?
Core Java
Ans. If we try to access an instance method from a static context , the compiler has no way to guess which instance method ( variable for which object ), you are referring to. Though, you can always access it using an object reference. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Q2052. Which are the thread safe / synchronized / concurrent classes in java collections ? Core Java
Ans. Stack
Properties
Vector
BlockingQueue
ConcurrentMap
ConcurrentNavigableMap Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  collections  concurrent classes Q2053. What are the differences between Intermediate and Terminal Operations in Java 8 streams? Core Java
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   Q2054. What is the difference between Collections.emptyList() and creating instance of a list ? Core Java
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   Q2055. Which are the classes that implement java.util.List interface ? Core Java
Ans. ArrayList
LinkedList
Vector
Stack Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Q2056. Why do you think that Stack collection class implement List interface ? Core Java
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   Q2057. What is the there only one method declared in Runnable interface? Core Java
Ans. The Runnable interface describes a class whose instances can be run as a thread. The interface itself is very simple, describing only one method ( run ) that is called automatically by Java when the thread is started. The Runnable interface is usually used in conjunction with the Thread class. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Q2058. What are scrollable ResultSet? Database
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   Q2059. What is difference between Executor.submit() and Executer.execute() method ? Core Java
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   Q2060. What is difference between CyclicBarrier and CountDownLatch in Java ? Core Java
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   Q2061. What do you mean by synchronized Non Access Modifier? Core Java
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   Q2062. Name few classes of java.util.regex package ? Core Java
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   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   Q2064. How to instantiate jsp variable from another jsp? JSP
Ans. using session attribute.
session.setAttribute("userId",userId);
in first jsp
int userId=session.getAttribute("userId");
in second jsp; Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 1 Companies Q2065. Explain toString method ? Which class contains this method ? Core Java
This question was recently asked at 'NEC Technologies'.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   Asked in 1 Companies 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   Q2067. What will the following code print and Why
class Class1 {
static{
System.out.println("Wow");
}
public static final int xyz=1;
}
class Class2{
public static void main(String[] args) {
System.out.println(String.valueOf(Class1.xyz));
}
} Core Java
Ans. 1
Reason being that Class1.xyz is replaced with 1 during pre compilation only and a reference to Class1 is never made. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  static final   pre compilation Q2068. Why java allows explicit import of class final static elements but not others ? Core Java
Ans. Because they can be replaced easily in pre compilation whereas others cannot. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Q2069. Why do we have multiple core java jars in java 9 ? Core Java
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  java 9  java modules   java 9 modules Q2070. What is the concept of modules in Java 9 ? Core Java
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  java 9  java modules   java 9 modules