Search Interview Questions | More than 3000 questions in repository. There are more than 900 unanswered questions. Click here and help us by providing the answer. Have a video suggestion. Click Correct / Improve and please let us know. |
|
| ||||
Interview Questions and Answers - Order By Rating | ||||
| ||||
This question was recently asked at 'LumenData'.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  database  rdbms  dbms  dbms vs rdbms Asked in 1 Companies basic | ||||
| ||||
Ans. No,we cannot.I t will give concurrentModificationExceptin error. It can be resolved by using ConcurrentClasses like ConcurrentHashMap,CopyOnWriteArrayList,BlockingQueue etc which are fail-safe and wont give exception. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  collections  list  iterator Asked in 1 Companies basic | ||||
| ||||
Ans. The process of hiding the implementation details from the user and providing only functionality. | ||||
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 | ||||
| ||||
Ans. Overriding refers to the Methods with same name and parameters, such that the later over rides the former method. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  oops  oops concepts  overriding Asked in 1 Companies basic   frequent | ||||
| ||||
This question was recently asked at 'MST Solutions'.This question is still unanswered. Can you please provide an answer. | ||||
Sample Code for composition | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  composition  object oriented programming (oops)  oops concepts  oops concepts Asked in 1 Companies basic   frequent | ||||
| ||||
Ans. The interface is a mechanism to achieve abstraction. Interfaces can have abstract methods and variables. It cannot have a method body. | ||||
Sample Code for interface | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  interface Asked in 1 Companies basic   frequent | ||||
| ||||
This question was recently asked at 'Adella software'.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  debug Asked in 1 Companies basic | ||||
| ||||
This question was recently asked at 'American International Group (AIG)'.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  applet Asked in 1 Companies basic   rare | ||||
| ||||
Ans. It is a file format based on the popular ZIP file format and is used for aggregating many files into one. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  jar Asked in 1 Companies basic | ||||
| ||||
Ans. The Java collections framework (JCF) is a set of classes and interfaces that implement commonly reusable collection data structures. Although referred to as a framework, it works in a manner of a library. The JCF provides both interfaces that define various collections and classes that implement them. | ||||
Sample Code for Map Sample Code for HashMap Sample Code for Treemap Sample Code for set Sample Code for hashset Sample Code for treeset Sample Code for list Sample Code for arraylist Sample Code for linkedlist Sample Code for queue Sample Code for priorityqueue Sample Code for concurrenthashmap Sample Code for vector Sample Code for stack | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  collections Asked in 9 Companies basic   frequent | ||||
| ||||
This question was recently asked at 'jspiders'.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 basic   frequent | ||||
Frequently asked in Genpact. | ||||
| ||||
Ans. Its is the process of creating exact copy of an object being cloned. In Object class one native method called clone() is there which is meant for Shallow Cloning of Object. Shallow cloning means bitwise copy of an object.In case of primitive data type it will create an exact copy of primitive values as well as variables but if the object contains any reference of an object then it will not copy the referenced object rather it will create the copy of reference variable and assigned it to the old object. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  cloning Asked in 3 Companies basic   frequent | ||||
| ||||
Ans. There are four main OOP concepts in Java. These are: Abstraction. Abstraction means using simple things to represent complexity. We all know how to turn the TV on, but we don?t need to know how it works in order to enjoy it. In Java, abstraction means simple things like objects, classes, and variables represent more complex underlying code and data. This is important because it lets avoid repeating the same work multiple times. Encapsulation. This is the practice of keeping fields within a class private, then providing access to them via public methods. It?s a protective barrier that keeps the data and code safe within the class itself. This way, we can re-use objects like code components or variables without allowing open access to the data system-wide. Inheritance. This is a special feature of Object Oriented Programming in Java. It lets programmers create new classes that share some of the attributes of existing classes. This lets us build on previous work without reinventing the wheel. Polymorphism. This Java OOP concept lets programmers use the same word to mean different things in different contexts. One form of polymorphism in Java is method overloading. That?s when different meanings are implied by the code itself. The other form is method overriding. That?s when the different meanings are implied by the values of the supplied variables. See more on this below. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  oops  oops concepts Asked in 16 Companies basic   frequent | ||||
| ||||
This question was recently asked at 'Intel'.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  abstraction  oops concepts Asked in 1 Companies basic | ||||
| ||||
Ans. Objects that have lost their reference i.e. they cannot be accessed/used by the program anymore. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  garbage collection Asked in 1 Companies basic | ||||
| ||||
Ans. Getting parent class object properties into child class is called Inheritance. The process of representing one form into multiple forms is called polymorphism. | ||||
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  polymorphism  object oriented programming (oops)  oops concepts Asked in 1 Companies Basic   frequent | ||||
| ||||
Ans. No. No interface provides any implementation and hence the declaration isn't viable. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  interface basic | ||||
| ||||
Ans. By using static and final modifiers. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  constant variables   static final basic   frequent | ||||
| ||||
Ans. java.lang | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  java.lang  import statement basic | ||||
| ||||
Ans. No, to run application, machine needs just a JRE (Java Runtime Environment) | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  jvm  jdk Basic | ||||
| ||||
Ans. No without main method can not be executed it will throw an error illegal start of type. Main method is the entry point of application. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  jvm  compilation  main method Basic | ||||
| ||||
Ans. Stack is based on Last in First out (LIFO) principle while a queue is based on FIFO (First In First Out) principle. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  data structure  stack vs queue  stack  queue Basic | ||||
| ||||
Ans. char is a primitive data type. String is a class. Char is a wrapper class for primitive char. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  char  string  data type Basic | ||||
| ||||
Ans. String is not a primitive type in java. Anything defined within double quotes like "abc" is an object of String class. | ||||
Sample Code for String | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  string  data type Basic | ||||
| ||||
Ans. Ternary operator , also called conditional operator is used to decide which value to assign to a variable based on a Boolean value evaluation. It is used as condition ? value1 : value2 For example int y = (x > 0) ? x:0; // assign x if it's greater than 0, else assign 0 | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  operator  ternary operator Basic | ||||
| ||||
Ans. Infinite loop is a programming condition wherein the control goes into an infinite loop because the loop termination condition can never be met. For example - for(int x=1;x>0;x++){ } in this loop, with each increment the condition x > 0 will remain true till infinity. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  loop  infinite loop  for loop  control statements  loop statement basic | ||||
| ||||
Ans. for, while and do while | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  loops  different type of loops  for loop  control statements  loop statement basic | ||||
| ||||
Ans. Yes that's legal in java | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  inner classes  nested classes  sub class Basic | ||||
| ||||
Ans. Yes that can be done public class OuterClass { public class InnerClass extends OuterClass { } } | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  inner classes  nested classes  sub class Basic | ||||
| ||||
Ans. Inner Class is a class that is nested within another class whereas sub class is a class that extends or inherit another class. Inner class can only be accessed using reference of outer class ( Class name , if inner class is static or object reference, if inner class is non static ) whereas Sub class is accessed directly. In terms of memory, inner class is stored just like another class having it's own body whereas sub class carries the body of parent class as well as it's own fields in memory. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  inner classes  nested classes  inner class vs sub class  nested class vs sub class Basic | ||||