Interview Questions and Answers - Order By Newest Q1351. Have you worked on creating any cron job ? 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   Q1352. Have you used any framework to capture command line arguments or options ? 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   Q1353. How would you choose your favorite company name for e.g. three companies are given in radio buttons Infosys, TCS and Aricent. Do You need to loop trough all radio buttons and select your favorite company or can just get the selected value. 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   Q1354. Write code to get count of every 5 letter word in a string using lambda expression
Core Java
Ans. String str = "I had been saying that he had been there";
Map<String,Long> countWords = Arrays.asList(str.split(" ")).stream().filter(p->p.length() = 5).collect(Collectors.groupingBy(p->p,Collectors.counting()));
System.out.println(countWords); Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  Collectors  lambda  filter  coding  java 8 Q1355. Can you write code so that we can keep track of Keys that have their values changed along with the number of times they were changed. 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   Q1356. What are the different types of methods in Java ? Core Java
Ans. Static Methods
Instance Methods
Accessor / Mutator or getter setters Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Q1357. Are getters setter / accessor mutator methods instance methods or static methods ? why ? Core Java
Ans. They are usually instance methods. They are usually applied to DAOs / DTOs / POJO that are used to transport objects and used to access object elements. As they are tied to objects and are not common to all objects of a class, hence they are created as non static. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Q1358. Design a class that find all files with SSN. Core Java
This question was recently asked at 'The Home Depot'.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 Q1359. Describe inheritance and polymorphism and their importance for OOP. Core Java
This question was recently asked at 'The Home Depot'.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 Q1360. What is the difference between instantiation and initialization ? Core Java
Ans. Instantiation is the process of reserving memory for the object
For ex -
List list = new ArrayList();
Initialization is the process of setting the default value for the object or default object construction.
List list = new ArrayList(set); Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Q1361. Why do we need to close the Scanner ? Core Java
Ans. For releasing input stream reference (System.in), you should close scanner. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  scanner  input output  io Q1362. Can you explain filter and collectors in java 8 ? Core Java
Ans. Filters are used to filter object in stream on certail criteria. And collector is used to collect outcome of the stream. Collector is a terminal operation.
List numbers = List.of(1,2,3,4,5,6,7);
List evenNumbers = numbers.stream().filter(n -> n%2==0).collect(Collectors.toList());
The above code will filter out odd numbers and return the list of even number. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  collector  filter Q1363. Can you explain filter and collectors in java 8 ? Core Java
Ans. Filters are used to filter object in stream on certain criteria.
Collector is used to collect outcome of the stream. Collector is a terminal operation.
List numbers = List.of(1,2,3,4,5,6,7);
List evenNumbers = numbers.stream().filter(n -> n%2==0).collect(Collectors.toList());
The above code will filter out odd numbers and return the list of even number. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  collectors  filters  java 8 Q1364. Write a program that identifies numbers in a list that are palindrome and perfect square ? Core Java
This question was recently asked at 'Spillman 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 Q1365. Write a program to sort the Array of Strings Core Java
Ans. String[] s = { "sort", "string", "array" };
Collections.sort(Arrays.asList(s));
System.out.println(Arrays.toString(s)); // [array, sort, string] Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 1 Companies Ans. Collection is a container which is used to store and manipulate the group of objects Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 1 Companies Q1367. Get all numbers from a collection that are both perfect square and palindome Core Java
Ans. public static void main(String[] args){
List<Integer> listOfIntegers = Arrays.asList(1,2,3,4,5,6,7,8,9,10,11);
List<Integer> perfectAndPalindromeIntegers = new ArrayList<Integer>();
for(Integer i: listOfIntegers){
if(isPalindrome(i) && isPerfect(i)){
perfectAndPalindromeIntegers.add(i);
}
}
System.out.println(perfectAndPalindromeIntegers);
}
private static Boolean isPalindrome(Integer i){
String str = String.valueOf(i);
char[] charArray = str.toCharArray();
int x = 0;
int y = str.length()-1;
while(x < y){
if(charArray[x] != charArray[y]){
return false;
}
}
return true;
}
private static Boolean isPerfect(Integer i){
for(int x=2;x<3;x++){
if(x*x == i){
return true;
}
}
return false;
} Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Q1368. When to use List, Set and Map in Java Core Java
Ans. I. If we want a Collection that does not store duplicate values, then we use a Set based collection.
II. If we want to frequently access elements operations based on an index value then we use a List based collection. E.g. ArrayList
III. If we want to maintain the insertion order of elements in a collection then we use a List based collection.
IV. For fast search operation based on a key, value pair, we use a HashMap based collection.
V. If we want to maintain the elements in a sorted order, then we use a TreeSet based collection. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 1 Companies Ans. The garbage collection is a facility wherein a program runs on the Java Virtual Machine which gets rid of objects, which are not being used by a Java application anymore. It is a form of automatic memory management and recollection. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 4 Companies Q1370. Can we change return type of Overridden method ? Core Java
Ans. Yes, we can change return type of overridden method in child class but child's return type should be sub-type of parent's return type. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 1 Companies Q1371. Find Intersection/union between two arrays. Core Java
This question was recently asked at 'Bristlecone,Amazon Lab126,Amazon,Microsoft,Facebook,NCR,Google'.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  arrays  code  coding Asked in 7 Companies   frequent Q1372. Find unique values between two arrays using single for loop ? Core Java
This question was recently asked at 'Net connect'.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  for loop  control statements  loop statement Asked in 1 Companies Q1373. Make "I Know Java" as "I Java Know" without using any inbuilt functions. Core Java
This question was recently asked at 'iOPEX 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 Q1374. Find out the max and min number from given array Core Java
This question was recently asked at 'Expedia'.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 Q1375. Math.round method rounds the decimal to an integer by stripping off the decimal places. How can we use the same method to keep only 2 decimal places
For example -
Math.round(12.3456) will return 12. What should we do to get 12.34 without using any other class or method. Core Java
Ans. We can multiply the value by 100 and then use Math.round on that and then divide the result by 100
For example -
(Math.round(12.3456 * 100)) / 100 Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  Math.round  double Q1376. What is the difference between round and scale method of BigDecimal ? Core Java
Ans. Round method would round it to integer places irrespective of if it's decimal places or not whereas scale would only round the decimal places. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  BigDecimal  round  scale Q1377. Which of the Core Java functions / packages / concept do you believe have become irrelevant in today's market ? 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   Q1378. What is the difference between subscribe and blockingSubscribe method ? RxJava
Ans. blockingSubscribe will block the current thread and wait till the chain completes Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Q1379. Difference between concatMap and flatMap ? RxJava
Ans. Flatmap converts stream(s) into a single streams without maintaining a order where as concatmap does the same along with maintaining the order
flatmap example -[[1,2,3],[4,5,6],[7,8,9]] -> [1,4,7,2,5,8,3,6,9]
concatmap example -[[1,2,3],[4,5,6],[7,8,9]] -> [1,2,3,4,5,6,7,8,9] Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Q1380. What are the drawbacks of Reactive extensions ? ReactiveX
Ans. Reactive extensions have a steep learning curve which makes it confusing for beginner and intermediate developers. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  RxJava  ReactiveX  Reactive Programming