Mikalai Zaikin

Bartender
+ Follow
since Jun 04, 2002
Merit badge: grant badges
Cows and Likes
Cows
Total received
40
In last 30 days
0
Total given
0
Likes
Total received
240
Received in last 30 days
0
Total given
409
Given in last 30 days
2
Forums and Threads

Recent posts by Mikalai Zaikin

I think it's more English language area
"at most one" means "not more than one" (IMHO)
and "one" falls into this category
I would say there is a big difference between stream and stream pipeline ;)
Stream is an approach to access data stored in some backed storage (collection, file, generator)
Pipeline -- consists of a stream, zero or more intermediate operation, and exactly one terminal operation.

Greg Charles wrote:I'm curious where you're getting that snippet from though?



It's from IDE debugger 8-)
Yes, the fourth line is blank
It's not because of println
The new line after "b" is surely counted, and length supposed to be 6

[UPDATE] After re-reading I see you also mentions "space before a"
There is no space before a, it removed as the c is on the same position.
The plain string is like that: "a\n[space]b\nc"
I may be wrong, but my understanding is: each operand is evaluated from left to right

So it will be like

4 (x pre-incremented and evaluated to 4 and x=4 after that) * 5 / 4 (evaluated to 4, and x=3 after post decrement) + 2 (as x=3 and pre-decremented before evaluating, and x = 2 after that)

which gives

4 * 5 / 4 + 2 = 7

and x = 2 (basically 3, incremented once, decremented twice)
Stephan I think you're wrong, and Albert is right.
This is a common mistake, string pool stored in Java heap memory starting with Java 7, and here 4 objects are eligible.
Is the D mentioned as correct option in the explanation?
If yes -- then probably this is an error.
No, it's simply a final variable.

You can refer JLS, let me do it for you:

A constant variable is a final variable of primitive type or type String that is initialized with a constant expression

Hi Hasan:

In short, this is compile time constant (compiler can determine it's value at compile time and it won't change):

final int i = 1;

this is also a compile time constant (in the context of the declared 'i' above):

final int j = i + 1;

this is not compile time constant, as the method may return anything :

final int k = j + getSomeValue();

For more details: please check here
Hi Gerardo !

Welcome to CodeRanch !

In the constructor:



x is initially 10 (passed in from the main method)
then x is reassigned 4
then end is assigned 4 and stored as final instance variable

The rest should be clear.

It's a bad practice reassign passed in parameters, and you can declare them final in method declaration to avoid such problems, but the exam is not about good coding style, it may show you horrible tricky code which you will never want to use in your work.

HTH,
MZ

Hi Mike!

Simon is right the line initially was 9 chars length:

Like that (space denoted as underscore):

a\n\n_b\n\nc\n

Once you indented, each line got an extra space:

_a\n_\n__b\n_\n_c\n

Now the length becomes 14.

HTH,
MZ
Yeah, it's a bit tricky, but as soon as you have String as the first operand, the plus operation already not between two boolean operands, but between String and boolean operand.
I fully agree with you. Option E is correct, and option F is wrong.

P.S. Welcome to CodeRanch !