Make your own free website on

Object types






         cannot extend/depend on itself, if circular declaration detected when loadedthen ClassCircularityError is thrown.

         cannot have checked exceptions in a static initializer

         Body can contain fields, classes, interfaces, methods, instance initialzers, static initializers, and declaration of constructors.

         modifiers are public, final, strictfp(?) apply

         by default the class extends Object(if it doesnt extend anything else) therefore cannot extend Object

         A class that is accessible can be accessed through if the class implements a public superclass or superinterfaces (only those methods can be accessed) ex.

         instance initializers may not throw checked exceptions unless each constructor in the class throws the exception or one of its superclasses.8.6

         compile time error for an instance initializer to complete abruptly with a checked exception.

abstract class

         cannot be instantiated




         The subclass extending MUST implement abstarct methods, unless it is also abstract

         If there is an abstract method class must be abstract

Can have an abstract class with no abstract methods

final classes

         cannot be final abstract

         cannot be extended



o        cannot be abstract, static, final, native, strictfp, or syncronized 8.8.3

o        first statement must be a call to an otherconstructor or to super, if not super is set by the compiler by default unless Object.

o        An explicit constructor invocation statement in a constructor body may not refer to any instance variables or instance methods declared in this class or any superclass, or use this or super in any expression (this only when calling an other constructor)

o        default constructor has the same access modifier as the class

         Can have a private constructor, in which case the class instantiation(if needed) done through static method.

         not considered to be a member so not inherited

         can throw just like methods8.8.4


         a method cant have abstract with any one of private, static, final, native, strictfp, or synchronized.

         a method cannot have native with strictfp.

         A static method cannot be overriden by a instance method.>

         an abstract method cannot be private. nor can it be static or final

         It is not possible for two or more method with the same signature not to be abstract, because non abstract methods are inherited from a direct superclass(no multiple inheritance)

         Only accessible non-static methods can be overridden( an abstrct class can override an abstract method by providing an other abstract method declaration.

         native methods like abstract end with a semicolon only.

         for inheriting two methods with the same signature:

o        if one of the methods is not abstact is static then error

o        otherwise the method that is not abstract considered to verrdie, and implement the abstract method, error will occur for different return types or throws clause that conflicts with abstract type.

o        if both are abstract, then abstract class inherits all abstract methods. Error will occur if there are different return types(or return type and void), throws clause do not cause error in this case.





         all variable modifiers apply, as long as they abide by modfier rules

         If a class declares a variable that is declared in the super class the super class variable is hidden(called hidding). The two variables can of different types, can use qualified name or field access expression(ie super) to access these vars(8.3)

static methods

         cannot be abstract

         cannot access this or instance variables

         A static method cannot hide an instance method



         static methods can be hidden ie you can declare a static method in the subclass with the same signature as a static method in the superclass. The superclass method will not be accessible from a subclass reference

         can be syncronized in which case the lock associated with the class is used.

static variables


         known as class variables

         it is a compile time error if a blank final static variable is not assigned (

         a final variable(not static) must be assigned at the end of every constructor

         a static variable can hide an instance variable.

both static and instance variables

         overriding method cannot throw more exceptions than the super method

         cannot be more restrictive than the method being overriden.

         cannot override methods with different return types

         private methods cannot be overriden or hidden.

         a hidden method can be invoked by using a referance whose type is the clas sthat actually contains the declartion of the method (not the case for instance methods which must use super)

         static initializers and instance initilizers are not members therefore not inherited

         It is a compile time error for a variable initilizer for static field or for a instance vriable of a named class can complete abruptly with a checked exception

         for initializing blocks a var can be on the lhs of expression before declaration or can be used using this, otherwise compiler error.

         a class may inherit two or more fields with the same name through inheritance or interfaces, but refereing to the field with it s simple name will cause a compiler errror, even if the vars have the same name same type and final.

         If the same field is re-inherited it may be referred to its simple name

         a class in the throws clasue must be the class Throwable or a subclass.

         Checked exceptions must be declared in the throws clause.




         Cannot implement the same interface more than once

         Can have the same class in more than one way(through inheritance)

         Unless the class implementing the interface is abstract all methods must be implemented


o        all methods are implicitly public abstract. 9.4

o        must not be declared static, strictfp or native or synchronized

         A class can implement more than one interface using one method, as long as the the method signatures are identical, if they conflict interfaces cannot be implemented(146)

         when syncronized the lock associated with this is used.

         every method is implicitly public abstract


         implicitly public static final

         Every field in the body of an interface must have an initialization expression


Member Inner Classes (non static)


cannot declare member interfaces

         Can access ALL outer class variables. Use outerclass.this to access outer class.

         the ussual member modifiers public, private, protected, default apply

         can inherit, same rules apply as to classes





no static methods



no static variables unless they are final static, but can inherit them


Local Inner classes


o        When inheriting from inner classes the default constructor wont work instead you have to specify the constructor which uses an instance of the outerclass to call the constructor of the inner super class

o        There is no such thing as a member interface, a local interface, or an anonymous interface because interface is implicitly static

Can access ALL outer class variables, but cannot access variables inside the method unless they are final static.





no static methods



no static variables unless they are final static but can inherit them


Inner Classes Static


cannot access instance variables

o        Usual static rules apply, cannot access outerclass instance variables only static variables

o        member interfaces are implicitly static, not required to declare it as such.










Annonymous Classes


cannot contain static members

instance initializers can throw unchecked exceptions even if the super class or interface does not declare them


cannot have constructors