What will be the output of the following code?
--------------------
public static void main(String[] args) {
Pattern pattern = Pattern.compile("^([a-zA-Z]{4})(.*)([a-zA-Z]{9})$");
Matcher matcher = pattern.matcher("LikeAndSubscribe");
if (matcher.matches()) System.out.println(matcher.group(0));
}
What will be the output of the following code?
--------------------
public static void main(String[] args) {
List<Integer> list = Stream.iterate(0, n -> n + 1)
.limit(30).skip(1)
.collect(Collectors.partitioningBy(number -> number % 2 == 0))
.get(true);
System.out.println(list.size());
}
What will be the output of the following code?
--------------------
public static void main(String[] args) {
Stream.iterate(1, n -> n + 2)
.limit(8)
.skip(2)
.map(o -> o + " ")
.forEach(System.out::print);
}
What will be the output of the following code?
--------------------
public static void main(String[] args) {
List<List<Integer>> list = List.of(List.of(10, 20, 30), List.of(40, 50, 60));
Integer result = list.stream()
.filter(l -> l.stream().reduce(0, Integer::sum) > 150)
.flatMap(Collection::stream)
.findAny().orElse(0);
System.out.println(result);
}
What will be the output of the following code?
--------------------
public static void main(String[] args) {
System.out.println(getValue(1, 2, 3));
}
public static int getValue(int... values) {
return Arrays.stream(values).reduce(0, (a, b) -> a + getValue(b));
}
public static int getValue(int value) {
return (value + getValue());
}
public static int getValue() {
return 10;
}
What will be the correct option regarding the following Java code snippet?
--------------------
interface ParentClass { }
class FirstChildClass implements ParentClass { }
class SecondChildClass implements ParentClass { }
If a class inheriting an abstract class does not define all its methods, then it will be known as (we will be forced to make it)?
What will be the output of the following code?
--------------------
public static void main(String[] args) {
int[] arr = {5, 2, 7, 1, 8};
Arrays.sort(arr, 1, 4);
System.out.println(Math.floorDiv(arr[0], arr[2]));
}
What will be the output of the following code?
--------------------
public static void main(String[] args) {
String str = "Like and Subscribe";
System.out.print(str.replace("i", ".") + " | ");
System.out.print(str.replaceAll("i", "."));
}
What will be the output of the following code?
--------------------
public static void main(String[] args) {
String str = "Geekific";
Arrays.sort(str.toCharArray());
StringBuilder reversed = new StringBuilder(str).reverse();
System.out.println(reversed);
}
What’s up fellow coders and welcome to Geekific!
I’m Ed, a full-time software developer and coding enthusiast. Join me on this never-ending learning journey as we dive into the fascinating world of coding. Whether you're a beginner or an experienced programmer, this channel is dedicated to providing you with valuable insights, tips, and tutorials to help you excel in your coding endeavors. Let's forge a tight-knit community of passionate learners and embark on an exciting coding adventure together!