Infosys Java8 Coding Interview Question Answers

preview_player
Показать описание
In this video, we solved Java Coding Interview Question which was asked in Infosys Interview. The candidate had 2 Years of Experience working as a Java Developer, He solved the problem using Java 8 features and got selected with CTC of 8 LPA.

#leetcode
#java
#interview
#javaprogramming
#javacoding
#javainterviewquestions
#InfosysInterviewQuestions

For Complete Java Interview Preparation Watch this Playlist:
Рекомендации по теме
Комментарии
Автор

That helps a lot.
Thanks a zillion.
The other way to get the desired output is

import java.util.*;
import java.util.stream.*;
import java.util.function.*;

public class MyClass {
public static void main(String args[]) {
List<Integer> intList = Arrays.asList(2, 4, 6, 8);
Long totalNum = intList.stream().collect(
Collectors.filtering(x-> x % 2 == 0,
Collectors.counting()
)
);

if(totalNum == intList.size())
System.out.println("All the numbers are divisible by 2");
else
System.out.println("All the numbers are not divisible by 2");

}
}

jeckrazi
Автор

Hi @CloudTech,
The other way is given below


import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
public class MyClass {
public static void main(String args[]) {
List<Integer> intList =
long divTwoList = intList.stream().filter(p-> p % 2 == 0).count();
if(divTwoList == intList.size())
System.out.println("All numbers in the given list are divisible by 2");
else
System.out.println("All numbers in the given list are NOT divisible by 2");
}
}

jeckrazi
Автор

Hi can you pls tell me if the panel gives the coding problem at runtime or it is on the coding platform

SR_INFORMERS
Автор

Like these questions are asking for interview of java developer with 2years experience sir? Is it for Sure sir?? Im preparing now thats why asked !

muhilkannan
Автор

can u please also provide interview questions?

saurabhfirke
Автор

Hi @CloudTech

One more way


import java.util.*;
import java.util.stream.*;

public class MyClass {
public static void main(String args[]) {
List<Integer> intList = Arrays.asList(10, 6, 2, 6, 4, 8);
int totalSum =
int towDivisibleSum = intList.stream().filter(p -> p % 2 ==

if(totalSum == towDivisibleSum)
System.out.println("All the numbers are divisible by 2");
else
System.out.println("All the numbers are NOT divisible by 2");

}
}

jeckrazi
welcome to shbcf.ru