ok, first example: In class Hello you have this line: byte b = 126;
Looks quite easy, but a few things happen here: The 126 is not a byte, it is a literal of type int. But the compiler sees, that it "fits" into a byte, converts the int literal to a bit and assigns it to the variable.
In the next line similar action with the int literal 3.
By the way, there are no such things as byte literals. This only in between.
The last line before the output was byte d = (byte) (b+c);
The part b+c is also not so trivial as it might look in first place. You use the operator +
That means, that if the operands are type byte, char or short, all will be converted to int and the result of the operation is also an int. The compiler cannot know at compile time if the result fits into a byte, so you have to cast explicitely. With this manual cast, you just skip the first bits of the integer, remaining only the rightmost 8 bits of the 32 of the int.
In the second example (class Test) however you have a single line that does not compile: byte c = 128;
Compiler recognized that the int literal is too big (one too big exactly) and so it does not compile. The rest of the class would be ok.