Win a copy of Rust Web Development this week in the Other Languages forum!

Priyanka Leo

Ranch Hand
+ Follow
since Sep 14, 2020
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
5
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Priyanka Leo

ahhh now i get it!!! i was breaking my head about this!! thanks!!!
Hi Guys,

I was doing the enthuware mock test and came accross the below code. I understand line 1 and 3 return the largest number that is 9. I cannot understand why line 2 and 4 return 3 can someone please help me understand the logic behind this code. Been breaking my head to understand this!!.



Thanks in advance
Hi Guys!!!
I was going through the below code and i believe it should return different results for parallel stream. As it dint satisfy the first condition:



bu this can be true only if identity is 0 but in this case its 1. I am not sure if my understanding is wrong . guys please help me understand the same.



Thanks in advance
i also tried with the below Program:

String[] os = new String[]{"Mac", "Linux", "Windows"};
Arrays.sort(os);
System.out.println(Arrays.binarySearch(os, "Max"));

and i got the output as -3 am i missing something here ??
Can you please clariify i am really confused
In this case if we search the single/ three/ Four charachter will it return the existing elements position. Is that what youy mean to say?
Guys

I am aware that forEach method takes only consumer but the below code the takes a submit method and it returns a value.
I expected a compiler error. But it compiled. Can someone please help me understand the same.




Thanks in Advance!!
Guys i have a doubt in the below question:

Assuming the current directory is /seals/harp/food, what is the result of executing the
following code?

A. 0
B. 1
C. 2
D. 3
E. 4
F. The code throws a runtime exception because of line h1.

I understand that the getNAmeCount is 3 and the answer is d but in the book its mentioned as B. Can someone please help me understand!!
Thanks in advance!!

Dears,

I am not able to understand the explanation given in the book for the below code. Can someone please help me understand the same.

Options:
A. ok
B. too high
C. Compiler error on line x1.
D. Compiler error on line x2.
E. Compiler error on a different line.
F. A runtime exception is thrown.


answer:
C. The functional interface takes two int parameters. The code on line x1 attempts to use
them as if one is an Object, resulting in a compiler error making C the correct answer. It
also tries to return String even though the data type for the functional interface method is
boolean. It is tricky to use types in a lambda when they are implicitly specified. Remember
to check the interface for the real type.



Thanks in advance!!
Dears,

I have a doubt in the below code. I expect the output to be "In Threader" but the output is "In Pooler". Can someone please help me understand this code



Thanks in advance!!
Dears,

I was practicing a mock test in Enthuware and i came across this question.



Select correct statements.

Options:

a.This is not a valid Comparator implementation.
b.Arrays.binarySearch(sa, "cc", new MyStringComparator()); will return -2.
c.Arrays.binarySearch(sa, "c", new MyStringComparator()); will return 0.
d.Arrays.binarySearch(sa, "c", new MyStringComparator()); will return -1.
e.Arrays.binarySearch(sa, "c", new MyStringComparator()); will throw an exception.

My answer was b and d. But the correct answer is b and c.

I am not able to understand why c is the correct answer. As per my understanding the binarysearch would search for the position where the correct element would exist if its not present and will  calculate based on(-(index-1)
I am not sure if  i am missing something. Can you please help me understand the same.

Thanks in Advance!!
Guys,

in the below program i understand that the processing starts from the right side
so in the first accept method 5 is printed and incremented to 6.
and the  andthen method is suppose to print 6. However the output that i get is 56.
Can someone please clarify.

Thanks in Advance!!
Guys

I am aware that consumer takes a parameter and does not return anything !!

But the below two programs are quite confusing for me Can someone please help me understand the same.

This is the first program!
According to the explanation : printNames does not take any argument But the argument for forEach method requires a method that takes an argument and hence this doesn't compile




The below is the second program. Even in this program inside forEach a method that doesnt take any parameter is used but this doent throw any compiler error. Can someone please explain the difference.

I am not sure what i am missing here!!.

What will the following code print when compiled and run?

List<Student> slist = Arrays.asList(new Student("S1", 40), new Student("S2", 35), new Student("S3", 30));
Consumer<Student> increaseMarks = s->s.addMarks(10);
slist.forEach(increaseMarks);
slist.stream().forEach(Student::debug);

Thanks !!!



Hello Guys Given the below code and the choice of answers are :
a.process(fnames, t::eat);
b.process(fnames, t::calories);
c.process(fnames, TestClass::size);
d.process(fnames, Carnivore::calories);
e.process(fnames, Tiger::eat);

Out of which the correct answers are a,b,c

I understand that a and b are correct but i cannot understand why c is correct. as TestClass is no way related to the carnivores class. Can someone please help me understand the same.

Thanks in advance!!

Dears,

I was practcing for the OCP test and came across the below code. As per my understanding the answer that i assumed was 11 but the actual answer is 10. Can someone please help me undrerstand this piece of code.

Thanks in advance!!
Guys i was asked the below question:

How to increase the performance of the following code:



Could you please help me with the solution for this ..
4 months ago