Goerch Mosi

Greenhorn
+ Follow
since Dec 27, 2010
Merit badge: grant badges
For More
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
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Goerch Mosi

Hello everyone,
my last post here is long time ago but I kept reading in the forum.
Last friday I took the OCPJP 6 exam and I'm very glad that I passed it with 80%.
To be honest, I wasn't sure if I pass at all during the test.

I rescheduled the exam four times this year because I felt ill prepared.
So I'm very happy that it went out ok and next year I will start preparing for the OCEJWCD.

Good luck to everyone that is preparing for the exam right now.
If you read and understood the SCJP Book from Sierra/Bates and went through a couple of mock exams everything will be fiine. ;)
11 years ago
a byte is singend and has a total length of 8 bits.
The first bit is for the sign (0 = positive, 1 = negative) and the other 7 bits for the number.

The binary represantion for 127 is 01111111

When you add 1 to that the binary turns into 10000000 ( = -128)

The first bit turns to 1 so that the value is negative.

If you add 1 to 10000000 you get 10000001 which is -128 + 1 and results in - 127

ankur trapasiya wrote:can anyone please clear my doubt ?



I will give it a try. ;)


The reference says that the InputMismatchException is

Thrown by a Scanner to indicate that the token retrieved does not match the pattern for the expected type, or that the token is out of range for the expected type.



That's why it is a good idea to use a try-catch. You have a try-catch block in your code, but your while is outside of it.

In the line where you initialize the Scanner you don't define a delimiter so the whitespace is used by default.
In the while-loop you define that the loop will be executed until you don't find "Java" in the tokens that has been build from the Input that you gave to the scanner .
That is the case in the first attempt to find "Java" because the first word is "Sun" and so the loop stops and the Exception is thrown.
If you would use the word "Sun" as Pattern the loop will be executed once and then stop.

I edited the code a little bit, so that the while is in try-catch block and the Pattern is "Sun" instead of "Java."

You could try Using

tkn = sc.next(".*");


to see what happens. ;)


I'm not 100% sure if my understanding of the problem is right.

If you replace

b2 += 4;

with

b2 = b2 + 4;

it is stll not compiling.

But if you replace it with

b2 = (byte)(b2 + 4);

everythings fine.

I'm not sure, but i read somewhere that if you are using the + operator the operants will be implicitly be cast to int and you can't say myByte = int, so you have to cast it to byte.

I have no Idea though, why the ++ works.

Update: Ok, I was to late. ;-)
Hello O.Ziggy,
because you forgot to define the type at the row where you use headSet(1600)

Try this one. ;-)

setSubset = (TreeSet<Integer>)setTimes.headSet(1600);

Tadeusz Kopec wrote:...
And one of the answers given as correct is:

Well, given o.code.length() == 1, o.bal == 2, o.rate = 1 and
this.code.length() == 1, this.bal == 1, this.rate == 2 this.equals(o) will return true but this.hashCode() == 1 and o.hashCode() == 2 which does not fulfill the contract.
...



The contract says also:

For any non-null reference value x, x.equals(null) should return false.



If I call equals(null) with the code given above we will just end up with a NullPointerException

Seetharaman Venkatasamy wrote:Welcome ...



Thank you Seetharaman.
13 years ago
Hello ragi,
as I was a little bit uncertain about externalizable myself I googled for it and found this little but helpfull example.
13 years ago