Interview Questions and Answers - Order By Newest Ans. Generics are a facility of generic programming that were added to the Java programming language in 2004 within J2SE5.0. They allow "a type or method to operate on objects of various types while providing compile-time type safety. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  generics Asked in 7 Companies Q1982. What is ORM or Object Relationship Mapping ? Database
Ans. ORM is the mapping technique, which maps object with relational data model. As we know that in java we need objects we can not user data in relational(in table form). So ORM is set of guideline which allows us to map relational data model in object form. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  orm Asked in 1 Companies   frequent Q1983. What are the uses of Abstraction ? Core Java
Ans. Loose Coupling
Facilitates designing complex applications by making them modular. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  oops concepts  abstraction Asked in 1 Companies Q1984. What are the disadvantages of Bean Auto Wiring in Spring ? Spring
Ans. It can always be overridden with explicit wiring. Moreover it's confusing if we use both explicit as well as explicit wiring in the project. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  Spring beans  auto wiring  autowiring Q1985. How can we track of all objects created in an application ? Design
Ans. We can store the references in a collection by adding to those objects in the collection. We can create a class "ObjectRegistry" with a collection or multiple collections with a search algorithm to look for the already collected objects. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  objects Q1986. Why is JVM called Virtual machine ? 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  jvm Q1987. Lets say we have a set "set1" with objects of Class A, Class has a non static string called element1, Write a code ( using lambda expression ) to see if there is any object in the set with element1 = "Hello". Core Java
Ans. set1.stream().filter(p->p.element1.equals("Hello")).findAny().isPreent();
or
set1.stream().map(A::getElement1).anyMatch("Hello"::equals) Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  lambda expressions  java 8  java8  java 8 filter  findAny() Q1988. Which of the OOP's features facilitate dependency injection ? Design
Ans. Inheritance , Runtime Polymorphism and Composition. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  dependency injection  inversion of control  ioc  oops  oops features Q1989. Is Runtime Polymorphism possible without Inheritance ? Core Java
Ans. Yes, Runtime Polymprohism requires either Class inheritance or Interface implementation. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  runtime polymorphism  object oriented programming (oops)  oops concepts  method overriding  inheritance  object oriented programming (oops)  oops concepts Q1990. Is dependency injection possible if we don't have inheritance / Composition ? Design
Ans. Without composition - No, as it's the core of dependency injection.
With Inheritance - Yes, through interface implementation. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  dependency injection  inversion of control  ioc Q1991. Why is Java such an important Programming language ? Core Java
Ans. Because of following features
Object Oriented and hence helps build maintainable and easily enhanceable code.
Platform Independence and hence can be executed anywhere
Fast due to JIT compiler Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Q1992. Why Java is considered more purer object oriented language than C++ ? Core Java
Ans. Because of
lack of use of pointers,
Lack of structural programming and
Lack of Multiple Inheritance Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  oops  java vc c++ Q1993. Does Wrapper classes produces immutable objects ? Core Java
Ans. Yes Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  wrapper classes  immutable  immutability Q1994. Why shouldn't we use string concatenation extensively or in a loop ? Core Java
Ans. Because String being an immutable object creates a new object upon each concatenation cycle. If there is any such need , we should use String Builder whose objects are mutable. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  string  string immutable  immutability  for loop  control statements  loop statement Asked in 1 Companies Q1995. What do we mean by a Data Type ? Core Java
Ans. if you have similar type of data or objects or entities, then we can give them a type with unique name. And this name will be our Data type. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  data type Q1996. As root, if you have to assign the owner for the file and set only read permission for the owner, Write a unix command to do it. Unix
Ans. chmod 477 Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  unix commands  setting file permissions  chown  chmod Q1997. In the following code, which text will get printed immediately after Hello
for(int countx=0;countx<10;count++){
System.out.println("World");
for(int countx=0;countx<10;count++){
System.out.println("Friend");
for(int countx=0;countx<10;count++){
System.out.println("Hello");
break;
}
System.out.println("Buddy");
}
}
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  break statement Q1998. Which of the two - iteration or recursion - is slower ? Core Java
Ans. Any function call is slower than the code in the same method as Java has to maintain stack of meta and function call information. So recursion is slower. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  iteration  recursion  iteration vs recursion Q1999. In case of generic class declared like following , What can T hold
class MyClass<T>{
T element;
} 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  generics Q2000. If we have to specify a collection of a particular information like List of addresses, How can we represent that in a JSON ? JSON
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  json Q2001. Which type of testing involves use of mocking frameworks ? Testing
Ans. Unit Testing Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Q2002. Can and Should we mock calls in integration tests ? Testing
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   Q2003. What features would you like to see in Java 10 ? 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  java10  java 10 Q2004. Can we instantiate the object of derived class if parent constructor is private ? Core Java
Ans. No Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  constructor  private constructor Q2005. How do you design microservices? Design
This question was recently asked at 'Citigroup Bank,Sofi'.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  microservices Asked in 2 Companies Q2006. Can an enum extend another enum ? Core Java
Ans. No Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  enum Q2007. Can we have a sub enum within an enum ? Core Java
Ans. Yes Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  enum  enum within enum Q2008. Write a SQL to remove records with a duplicate field in a Table ? Database
This question was recently asked at 'Sofi'.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  sql Asked in 1 Companies Q2009. How can we make sure that we don't receive duplicate messages from the Kafka Topic ? Apache Kafka
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  kafka Q2010. If a Map needs to be accessed simultaneously by multiple threads, which collection class should be used ? Core Java
Ans. ConcurrentHashMap Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  map  concurrenthashmap  multithreading