Ren� Star

Greenhorn
+ Follow
since Feb 24, 2005
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 Ren� Star

Indeed, long is 64 bits, float 32. BUT widening/narrowing is not only about the number of bits. It is about if you can lose information when converting.
And when you convert from a floating type value (float or double) to an integer type, the decimals get cut off - loss of info.

Look at the list of types below. All conversions along the arrows from left to right are defined as widening conversions. All other conversions between non-equal types are narrowing conversions and require a cast.

This is the list you should learn/use for determining if casts are needed, not the actual size in bits of the types.



Note: the following requires a cast, even though char has more bits than byte.

For binary operands, the operators are widened to the largest type of the operators, and to integers if both operators are of a type smaller than int.

The order is:

byte -> short -
|-> int -> long -> float -> double
char -

The largest operator in b*c*s*i*f is of type float, so the result is also of type float.

Assignment to a smaller type needs a cast (with the exception of the byte/shot/char assignments with a fitting constant value).
Assignment to a wider type is automatic.

So the only valid types of the answer variable are types that are at least as wide as float. Long is smaller than float, so it is not valid.
The following link contains a tutorial for conversions, check it out:

Conversions
If I understand you well, the question was about legal definitions for (top-level) classes and interfaces.

This is not a definition of an interface indeed. It is a legal definition of a class however (if the braces are replaced by curly braces, of course )
The method clone() is declared protected in the Object class. Protected methods can be accessed from within the same package or from any subclass.

Obviously you are not in the same package, but you are a subclass of Object.
HOWEVER, there is a caveat in this: a class can only access a protected members of a superclass on objects of its own class (or one of its subclasses).

Here's an example:



Which brings us to the next question: why doesn't the String class override the clone() method with a public version?
Strings are immutable, and it would not make sense to make a copy of an immutable object. Say you have a string "abcde" somewhere in memory. Why would you want to have another string "abcde" in memory? You can not change the string anyway, so you can just assign the original reference.
Basically this is all there is to know about daemon threads:

1. You can have two types of threads inside a Java program, user threads and daemon threads.
2. A Java program terminates when all USER threads have died, regardless of the existence of any living daemon threads.
3. You can change the status of a thread by using the setDaemon method as long as the thread has not been started. If you try to change a started thread, you'll get an IllegalThreadStateException.

Relevant methods:
final void setDaemon(boolean flag)
If flag is true, the thread will become a daemon thread. Otherwise the thread becomes a user thread. (BTW, threads are created as user threads initially)

final boolean isDaemon()
Returns true if the thread is a daemon thread; false if it is a user thread.

Hope this helps.
Hi,

Could someone help me out with this: I want to make NetBeans compile into a separate build directory. I have set this up by setting the 'Target' in the compilation options. The compiled classes end up in the target dir as I want,
but when I compile again (Shift-F9), NetBeans does not recognize that the classes are up to date. How can I set it up so that the up-to-date check does look at the build directory instead of the source directory for checking if class files are up-to-date?

Cheers,
Ren�
Thank you all. Next I'll probably go for the SCBCD.

S javainn, the real exam is easier than the one in Mughal. It is about the same as the two practice exams from Whizlabs.

If you know Mughal by heart, you should be able to pass the exam with an 80% + score. How well you actually fare, depends as much on your analytical skills as on your knowledge of the exam objectives.

Make sure you completely understand multi-threaded programming. This is by far the most difficult concept covered by SCJP. I was lucky to have done lots of serious multi-threaded programming in a previous life. From my own experience and from what I read on the ranch, this topic is used a lot in the exam.

One last tip: take as many mock exams as possible. Studying the book gives you the basics to succed, but practice makes perfect.

Cheers,
Ren�
19 years ago
... in my heart it's spring. Or, rather, it's summer - lying under a palm tree on a white Carribbean beach.

With all the snow that fell around here, getting to the SCJP exam was almost as tough as taking it. But the end result was more than worth it: 95%! I'm SO proud of myself today :-)

It all started 12 days ago, when I decided to go for SCJP 1.4. Having ample development experience - but mostly in C - I decided to go for Mughal & Rasmussen. It turned out to be a great choice.

It took me six days to get through the book (including all the programming exercises). The next day I took the mock exam from the book to see where I was standing.

By then I knew that I would pass the exam, but now the REALLY hard part started. When I started studying, I set myself the goal to go for a 90% score. I think it really helps to set yourself a high target, as it makes you work really hard in order to completely understand everything.

I did a couple of the free mock exams available. Most helpful for me were the exams by Dan Chrisholm. The really helped me to identify the points, that I THOUGHT I knew when in practice I didn't comprehend them fully. Definitevely a humbling experience.

In between I re-read the book, but now much faster, scanning through the chapters and focussing on things I was unsure about. And learning all the method specs, of course (it really helps if you are 100% sure that finalize is defined as 'protected void finalize() throws Throwable', for instance).

Yesterday I made the 2 Whizlab practice exams available from the Mughal&Rasmussen book. They are really great in giving you a feeling of how the real exam works. And they gave me back my confidence that was somewhat crushed after the 'Chrisholm experience'. After that I took some time to relax and watch telly, reloading my batteries for the real deal.

This morning I took a quick look at the method definitions again before getting up. After that, I felt I was ready.

Thanks to all, who helped me achieving this great result: Mughal and Rasmussen, everyone who has created one of those great mock exams on the net, and of course all who wrote questions and answers in the SCJP forum.

But now I'm off to enjoy the sun, ahum, I mean snow. And that smile on my face won't go away for a few days, I'm sure ...
19 years ago
Thanks for the tip. I had already contacted them, and just after you wrote your post I received their helpful reply.
Great. I was just trying to install the Whizlab exam simulator that came with my copy of Mughal&Rasmussen. When I try to activate the simulator, I keep getting 'Server response failure,' though.
I can't find any information on how to get a UCK, so I can't do a manual activation either.

Any help on solving this problem quick would be greatly appreciated - my exam is tomorrow...

Ren�

Originally posted by Leandro Melo:
Hi.
This is a question form dan's exam.

Which of the following modifiers can be applied to a class that is not a nested class?
a. public
b. protected
c. private
d. abstract
e. static
f. final


Here's the list for the accessibility classes (public, private, protected):

1. Top-level class
public or none(=default/package accessibility)

2. Member class (nested class that is not inside a method or other block)
public, private, protected or none

3. Local class (class inside a block)
4. Anonymous class
For both types no accesibility modifiers are allowed.
There is no real logic in overloading the Float construtor with a double parameter (and not doing it for the Short parameter with int).

Now we have the following: