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.
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.
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.
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.
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?
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.
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);