Categories
Certification Java Programming SCJP

Compound Assignment Operators

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

Categories
Certification Java Programming SCJP

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

Categories
Certification Java Programming SCJP

Local Variables, as far as the SCJP is concerned

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

Categories
Certification Java Programming SCJP

Other modifiers, for members…

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

Categories
Certification Java Programming SCJP

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

Categories
Certification Java Programming SCJP

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

Categories
Certification Java Programming SCJP

Varargs, for those times when you’re not sure how many parameters you’ll have…

As of Java 5, methods are now able to accept from 0 to many arguments. Sounds confusing, but you could actually be using it already without knowing, how about looking at your main methods? As we can see above, var args are declared as TYPE… NAMEOFVARIABLE. Lets take a look at a basic example I’ve […]

Categories
Certification Java OO Concepts Programming SCJP

Coupling and Cohesion, what you need to know for SCJP…

Coupling and cohesion are two terms that often get mixed up, however they are actually really simple concepts, and the bonus is, they don’t just apply to Java. Coupling Coupling, in its purest terms, means “the degree to which one class knows about another class”. If one class uses another class, that is coupling. Coupling […]

Categories
Certification Java Programming SCJP

The Conditional (ternary) operator, cleaning up if-else assignments since 1996…

The conditional operator, or ternary operator as it is otherwise known is a great way for assigning variables based on boolean tests. For example you may have seen the following : Pretty simple right? However that if-else statement is a bit messy considering all we’re doing is checking a condition and then using the output […]

Categories
Certification Java Programming SCJP

Looping in Java, a brief look at the various loops and how they can be applied

One of the great features of any programming language is the ability to repeat blocks of code, sometimes indefinately, sometimes until a certain condition is met, or for a set number of iterations. Luckily, Java comes with several flavours of loops, let have a brief look at our options The “for” loop – The for […]