Interview Questions and Answers - Order By Rating 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 Javascript JavaScript
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 Q41. Have you had to work with memory leak problems in javascript ? JavaScript
This question was recently asked at 'RockYou'.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 Q42. Write a method to track every click on a page. JavaScript
This question was recently asked at 'LinkedIn'.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 Q43. What is the difference between inheritance in PHP vs. Javascript? JavaScript
This question was recently asked at 'WePay'.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  php  javascript Asked in 1 Companies Q44. Write a Program to draw a fish ? Core Java
This question was recently asked at 'Webkul 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   Asked in 1 Companies Q45. Should we do anything to avoid memory leaks in Java ? Core Java
Ans. Java has a intrinsic way of checking leaks and reclaiming memory called garbage collection. Moreover Java doesn't support pointer arithmetics , so there is very low comparative chance of memory leaks, compared to C,C++
Though there may be tools that may audit code to make sure that we are not leaving much for the garbage collection to work but I have never heard anyone doing anything for memory leaks in Java. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  memory leak in java This question was recently asked at 'Whitesnow 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   Asked in 1 Companies Q47. Is String mutable or immutable in Java ? Core Java
Ans. String is Immutable because of String Constant Pool. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 1 Companies Q48. What are different types of Polymorphism in Java ? Core Java
Ans. run time polymorphism
compile time polymorphism Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 1 Companies Q49. Can we assign the reference to this variable ? Core Java
Ans. No Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 1 Companies Q50. Hash map using/without using Java 8 Core Java
This question was recently asked at 'HCL 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 Ans. Throwable in java is a class that is the superclass of all exceptions and errors which may occurs in java program.It extends obcect class. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  exception handling   throwable Asked in 1 Companies basic 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   Q53. What is string pool and what is the use of intern() function ? Core Java
Ans. The Java String class intern() method returns the interned string. It returns the canonical representation of string. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 1 Companies Q54. How to make a collection thread safe? Core Java
This question was recently asked at 'Amodcs'.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 Ans. Java Comparator compares two Java objects in a “compare(Object 01, Object 02)” format. Using configurable methods, Java Comparator can compare objects to return an integer based on a positive, equal or negative comparison Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 1 Companies Q56. Why should we go for custom defined exceptions even if we have many exceptions provided already using throw keyword Core Java
Ans. It gives us the liberty to throw the specific exceptions which are required and also we can control the handling of exceptions Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 1 Companies Q57. How does Garbage Collector work? What are the realizations of Garbage Collector. Core Java
This question was recently asked at 'ExpertSoft'.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 Q58. How multiple catch block works ? Core Java
This question was recently asked at 'Capgemini'.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 Q59. What is the use of toString method ? Core Java
This question was recently asked at 'Jibe Technology 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   Asked in 1 Companies Ans. class:- A class describe the contents of an object, an it describe the detail of data field called instance variable and defines the operations called method.
Object:-An object is an element of a class. Object have the behaviors of their class. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 1 Companies