Categories
Certification Java SCJP

How I passed the SCJP / OCPJP

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 […]

Categories
Certification Java Programming SCJP

Continue and break, with and without labels, for the SCJP

Looping constructs are very useful in any programming language, however they can be come¬†particularly¬†complex when you have a variety of nested loops and you need to drop out from particular iterations, or exit the loops entirely under a set of given circumstances. Fortunately for us, Java provides us with 2 keywords that we can use […]

Categories
Certification Java Programming SCJP

Interfaces, declaring and implementing

Another bite-size SCJP blog post, this time we’ll tackle interfaces. Interfaces are, in the simplest terms, just a contract. It specifies things that a class must do if that class signs up to its contract, but it doesn’t provide any details of how those things must be done. For example, you may wish to create […]

Categories
Certification Java Programming SCJP

Polymorphism, a little overview with code samples

Polymorphism basically means that one thing can take many forms, and this is particularly useful for programmers, as it allows us to treat similar types of object in a single manner, yet the objects may actually be slightly different at runtime. One application of this might be where we have an animal class, we know […]

Categories
Certification Java Programming SCJP

Inheritance, some examples for SCJP study

Inheritance is a practice of one thing extending another. So you can more specific subclasses of a class. Inheritance is available in most programming languages, and in Java it is implied using the extends keyword. For example, you may have several objects like Car, Boat, Truck, these may all have common behaviour and state between […]

Categories
Certification Java Programming SCJP

Encapsulation; shielding state via the use of accessors

Encapsulation is a fantastic OOP concept of being able to shield class state via the use of accessor methods. Imagine that you have a class, perhaps called Person. This class will have some form of state, such as name, age, date of birth. These would most likely be stored against reference variables. If you left […]

Categories
Certification Java Programming SCJP

Overloading in Java, what it is and how you can use it, along with some examples

There are times when developing, when you need to do similar behaviour but with differing input arguments, for example you may have a method that prints something to the console. You may need to print Strings, Integers, and all sorts of other objects. You could (if you really wanted), create a method for each one […]

Categories
Certification Java Programming SCJP

Basics of the switch statement in Java

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 […]

Categories
Certification Java Programming SCJP

String concatenation operator

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 […]

Categories
Certification Java Programming SCJP

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, […]