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

Thorsten Schneider

Greenhorn
+ Follow
since Apr 04, 2011
Thorsten likes ...
Eclipse IDE Firefox Browser Linux
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
7
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 Thorsten Schneider

Java can be called a platform independant programming language, as long as there is a java virtual machine available for the operating system you intend to run the code on. This is possible due to the java compiler generating java bytecode rather than binaries.
10 years ago
Anytime you create an object of type Dozens, it has an int array called dz as a member variable. So line 6 is the first object of type Dozens[], line 7 are the next 2 objects created (one of type Dozens and one of type int[] associated with it), as well as line 8 where another Dozens object with it's associated int[] is created. That's a total of 5 objects.
The static methods yield() and sleep() aren't inherited!

But as the Thread class is part of the inheritance tree of your class the compiler will invoke those methods from the Thread class.
Congrats as well!

I took the exam yesterday and finished it with a score of 95%, so it's definitely a lot easier than the practice exams. I read the K&B study guide twice and read the two minute drills about half an hour before taking the test. I also used the K&B practice exams and scored an average of about 65-75% on the first three - leaving me a bit demotivated. So I just studied the topics I failed in the first three tests again and took half of the fourth test the evening before the exam (it was too late to do the whole test) and scored 28 out of 30 questions right, leaving me confident for the real thing.
10 years ago
The last one will compile, but it will cause an ExceptionInInitializerError at runtime caused by a NullPointerException, because you're trying to access an array, that hasn't been inizialized yet.
Well, there are only two possible values for 'code': 9 and 7. And in the whole code there is only one line of code that can change it (line 6): this.code = 7;
Although it isn't guaranteed, that the variables value will be changed to 7 before the whole for loop is done (therefore printing '99999'), there is no way a 9 could be printed, after(!) the variable has been set (and therefore remains) to 7.

Possible outcomes therefore are:

99999
99997
99977
99777
97777
77777
Hello Bert,

thank you for the clarification and for the confirmation of what I thought at first. Turns out I just misinterpreted the question. I simply had too many practice questions for today...

Thorsten
Hello, in KS&BB practice exam book, there is a question relying heavily on thread IDs. In that question the key point is: the first thread started after the main-thread has the ID 2. But if, e.g. I try it on my machine, thread IDs start at 9.

So, for the exam, can i take it for granted, that the ID of the first thread after the main-thread will be 2?

Thanks in advance for all answers.
Well, if you ignore those wrongly placed comments to clarify the lines for the answers, this code shows polymorphism for arrays and works well. It is perfectly fine for a bike[] reference variable to reference an arr[] array. All three array reference variables reference the same arr[] array object with a size of 2, holding null. Still, it produces no output.
You miss the creation of objects of type int[] whenever an instantiation of type Dozens occurs. These int[] can no longer be reached, if you can't reach the object referencing them.

So, let's start this over:

The first two assignements work, because the compiler can check, wether those two int literals(!) are in the range of a byte or not. With the third assignment the compiler only sees byte d = an int + an int and not the actual values these two int variables hold and therefore need to be explicitly downcasted to a byte. So it would work like this: byte d = (byte) (b + c);
Because, if you don't make an explicit call to super(arg) in the constructor of Rake, the compiler will insert an implicit call to super() (the no args constructor of GartenTool).

So effectively the constructor will look like this: