After procrastinating for many years (4 to be precise), I finally sat and passed the SCJP exam. The exam itself wasn’t particularly difficult, but theres a lot of things you can get tested on that you’ll rarely use in everyday development. Having been developing in Java for around 4 years now, I’ve never needed to […]
Tag: certification
If statements are great, but sometimes they are just not very practical when you have to test for more than a handful of conditions, have a look at this very poor example of how you build up a long set of if-else statements, its fine for a few checks, but if you’re doing multiple equality […]
The string concatenation operator is a bit like a hedgehog, it looks cute and sweet, but try to grab hold of it quickly and you’ll soon know about it… It’s actually quite simple, however there are some traps that are very easily overlooked (just got caught out with it on a mock test, so I’m […]
The instanceof Operator
The instanceof operator is a great way for checking if a reference variable is of a given type, in other words, does it pass the IS-A inheritance test. Ask yourself, is a Cat a Dog? A Dog a Cat? Or is a Cat an Animal and a Dog an Animal? In true Harry Hill style, […]
There are various compound assignment operators, however it is only necessary to know the 4 basic compound assignment operators for the exam, being as follows: += (Addition compound) -= (Subtraction compound) *= (Multiplication compound) /= (Division compound) Essentially, they’re just a lazy way for developers to cut down on a few key strokes when typing […]
Static members…
Statics are a rather strange beast, they belong to no instance of a class, they have no fixed abode, other than their class.. Consider the following example : Statics don’t belong to any instance, they belong to the class itself. So there is only ever one copy of a static member (method or variable). Statics […]
Local variables are variables that are declared locally, funny that eh? This one should be nice and easy, lets have a look at a quick example : Some really easy things to remember, local variables don’t ever get initialised automatically, so you have to do that yourself. The method above, doSomethingElse, the variable gets declared, […]
We’ve already touched upon various modifiers, for classes (both access and non-access), but there are also some more modifiers for members, as detailed here. We have the following modifiers for members : final – Can’t be overridden abstract – No implementation specified, subclass must implement synchronized – Only a single thread of execution can pass […]
Class Modifiers (non-access)
In addition to class access modifiers, classes can also be marked with non-access modifiers. These modifiers imply rules on a class, but are not necessarily linked to access rights. The following non-access modifiers are available: final – The class can’t be extended. abstract – The class has to be extended, and can’t be instantiated on […]
Class Access Modifiers
Class access modifiers define who can see the class, you use it on a daily basis, have a look at the following : There you go, you said “public class”, thats you saying that this class is public, and anything can access it. It is important to note, that even though a class may be […]