Interview Questions and Answers for 'Java' | Search Interview Question - javasearch.buggybread.com
Javasearch.buggybread.com

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.
Label / Company      Label / Company / Text

   



Interview Questions and Answers - Order By Rating

next 30
 Q11. What are the different ways of creating threads in java?Core Java
Ans. There are two ways to create the threads in java
a) By extending java.lang.Thread class.
b) By implementing java.lang.Runnable interface.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     


 Q12. What are Loops in Java? What are three types of loops?Core Java
Ans. Looping is used in programming to execute a statement or a block of statement repeatedly. There are three types of loops in Java:
1) For Loops
For loops are used in java to execute statements repeatedly for a given number of times. For loops are used when number of times to execute the statements is known to programmer.
2) While Loops
While loop is used when certain statements need to be executed repeatedly until a condition is fulfilled. In while loops, condition is checked first before execution of statements.
3) Do While Loops
Do While Loop is same as While loop with only difference that condition is checked after execution of block of statements. Hence in case of do while loop, statements are executed at least once.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     


 Q13. What is the difference between double and float variables in Java?Core Java
Ans. In java, float takes 4 bytes in memory while Double takes 8 bytes in memory. Float is single precision floating point decimal number while Double is double precision decimal number.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     


 Q14. Can main() method in Java can return any data?Core Java
Ans. In java, main() method can't return any data and hence, it's always declared with a void return type.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     


 Q15. What's the difference between an array and Vector?Core Java
Ans. An array groups data of same primitive type and is static in nature while vectors are dynamic in nature and can hold data of different data types.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     


 Q16. How to swap two numbers without using a third variable?Core Java
Ans. int a = 10;
int b = 20;

b = b + a; // now b is sum of both the numbers
a = b - a; // b - a = (b + a) - a = b (a is swapped)
b = b - a; // (b + a) - b = a (b is swapped)

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     


 Q17. Explain method overridding.Core Java
 This question was recently asked at 'Ksolves'.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     overridding  polymorphism     Asked in 1 Companies


 Q18. Write a program to print next largest palindrome number? Core Java
 This question was recently asked at 'Ksolves'.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


 Q19. What are the benefits of using UI framework like Angular , View js etc instead of plain vanilla js and html ?Javascript
Ans. These frameworks facilitates easier product development and enhancement and maintainability by having separation of concerns ( using oops ) and helps in development of reusable libraries / components. So in nutshell , they make development and maintenance of large scale application easier.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     Javascript Frameworks  Angular  View js


 Q20. Have you ever used sessionStorage ? What is the better way to store session information - sessionStorage or session cookie ?Session Management
Ans. Session Cookie, because session storage can be accessed from XSS (Cross site Scripting) attacks but cookies (if set with "HttpOnly" and "Secure" flags) are more safer against these attacks.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     SessionStorage  session cookie  session management  javascript


 Q21. String processing in JavaCore Java
 This question was recently asked at 'Chase'.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


 Q22. what is strict mode in javascript ? How is it used ?Javascript
 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     


 Q23. What is concurrent interface ?Core Java
Ans. ConcurrentMap is an interface and it is a member of the Java Collections Framework. It represents a Map that is capable of handling concurrent access to it without affecting the consistency of entries in a map. ConcurrentMap interface present in java.util.concurrent package.

HashMap operations are not synchronized, while Hashtable provides synchronization. Though Hashtable is thread-safe, it is not very efficient. To solve this issue, the Java Collections Framework introduced ConcurrentMap in Java 1.5.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     Concurrent Interface   java.util.concurrent   Java 8 Concurrency   java concurrency   java 8     Asked in 1 Companies


 Q24. What are the benefits of Java over other Programming Languages ?Core Java
Ans. 1. JVM that makes it platform independent and facilitates portability.
2. Garbage Collector that protects from Memory Leaks.
3. Only usage of references and not pointer arithmetic and hence protects the application from memory issues like dangling pointers, memory leaks etc.
4. Support for OOPs that makes application development and maintenance easy.
5. Facilitates library development through use of interface / abstract classes.
6. Facilitates creation of scalable applications.
7. Huge repository of libraries and pool of people with java skill.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     benefits of java  advantages of java      basic        frequent


 Q25. What is the different between collection and Stream Api ?Core Java
Ans. data under collection are actually stored in memory so that they can be retrieved when needed whereas data in streams are not stored and hence we need to construct it again when needed.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     collection classes  stream api  collection vs stream     Asked in 1 Companies


 Q26. How is cohesion achieved in JavaScript ?JavaScript
 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     


 Q27. How Object-Oriented Programming is implemented in JavaScript? How they differ from other languages?Javascript
 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     object oriented programming in javascript  oops in javascript


 Q28. Explain Servlet configJava EE
 This question was recently asked at 'Oracle financial services'.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     servlet  servlet config     Asked in 1 Companies


 Q29. Interface vs AbstractionCore Java
 This question was recently asked at 'Oracle financial services'.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     interface vs abstraction  interfacing vs abstraction  relation between interface and abstraction  How interface provide abstraction     Asked in 1 Companies


 Q30. How is the declaration of enum in Typescript differ from Javascript ?TypeScript
 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     enum typescript  enum javascript


 Q31. What are benefits of strongly typing variables ?JavaScript
 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     strong typing javascript


 Q32. Difference between Let and Var in Javascript ?JavaScript
Ans. Var scopes the variable to the nearest function whereas Let scopes the variable to nearest block.

For example -

function printNumbers() {
for(var i = 1; i < 3: i++){
console.log(i);
}

console.log(i); // works fine and will print 3 as i has a function scope and not local loop scope
}

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     let vs var in javascript  let vs var   difference between let and var


 Q33. How can we create an arraylist of unique values ?Core Java
Ans. We can put the value in a set to enforce uniqueness and then dum those value into an arraylist.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     arraylist  design  collections


 Q34. Why wait(), notify(), notifyAll() methods are in Object class instead of Thread class?Core Java
Ans. wait() and notify() methods are defined in Object class rather than Thread class.If wait() and notify() were on the Thread instead then each thread would have to know the status of every other thread and there is no way to know thread1 that thread2 was waiting for any resource to access.Hence, notify, wait, notifyAll methods are defined in object class in Java.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve          Asked in 1 Companies


 Q35. Can the value of a static variable be changed ? Core Java
Ans. Yes the value of a static variable can be changed. It's the final keyword that restrict the modification of value not static.


 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     static variables


 Q36. What are the advantages and disadvantages of Lambda Expression ?Core Java
 This question was recently asked at 'Number 8'.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     java8  java 8  java lambda expressions     Asked in 1 Companies


 Q37. Write a unit test case using java 8.JUnit
Ans. public List convertAllToUpperCase(List words) {
return words.stream().map(String::toUpperCase).collect(Collectors.toList());
}

@Test
public void testAllToUpperCase() {
List expected = Arrays.asList("JAVA8", "STREAMS");
List result = convertAllToUpperCase(Arrays.asList("java8", "streams"));
assertEquals(expected, result);
}

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java8  java 8     Asked in 1 Companies


 Q38. Write a program to make an array act as a set.Core Java
Ans. public Set convertArrayToList(T array[]) {
Set set = new HashSet<>(Arrays.asList(array));
return set;
}

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     arrays  collections set     Asked in 1 Companies


 Q39. What is the use of defining equals , compareTo and hashcode methods in a class ? Where are they used ?Core Java
Ans. equals, compareTo and hashcode are of use when the objects are used within collections.

Equals helps with collections that helps maintaining only unique objects ( like Set )

compare and compareTo helps with collections that helps maintaining objects in order ( TreeSet, TreeMap etc )

hascode helps with collections that facilitates hash searching ( like hashSet, hashMap etc )

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     equals    compareTo   hashcode method


 Q40. prototypal inheritance in JavascriptJavaScript
 This question was recently asked at 'RocketMiles'.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


next 30

Help us and Others Improve. Please let us know the questions asked in any of your previous interview.

Any input from you will be highly appreciated and It will unlock the application for 10 more requests.

Company Name:
Questions Asked: