Saturday, March 27, 2010

11 - final

variable
http://www.witscale.com/ebook/Browsable/ebook065.htm

method -
final method cannot be overridden

class-
final class cannot be subclassed

Friday, March 26, 2010

2- identifier naming

a) should not start with a number

b) can start with an alphabet $ _

c) java is case sensitive

1- source file naming convention

a) There can be only one or zero public class per file and any number of non public classes

b) If there is a public class then file name should match the public class name

c) There can be only one package statement and any number of import statements but package statement should be the first line and import statements should immediately follow if they are there

d) public class can be the first class or come in between or after any number of non public classes

e) there can be a main method in one or any number or classes in the source file

6 - local variable

a) only final modifier can be used

b) has no default value so it has to be assigned a value before it can be used

5- this

a) used to refer to any member of same  class or inherited member

b) actually no need to specifically use ' this . ' we can simply use the member name

c) this always refers to currently executing object

10 - abstract

a) If an abstract method is not visible in a subclass then that subclass is abstract even if it implements a method with same name

b) If a class inherits a method with same name as abstract method and abstract method is visible to it, then it is non abstract even if the super class from which it has inherited is abstract due to a)

c) if anywhere in the inheritance hierarchy you have a non abstract class then all it's subclasses are also non abstract unless they define an abstract method

d) polymorphism and overriding work in the same way as non abstract method.

e) runtime error- java.lang.Abstract method error occurs when you try to invoke an abstract method.

particularly at compile time you can invoke an abstract method using abstract class reference but at runtime if the actual object does not have a valid overridden method then this error will happen

9 - static

a) static methods when being redefined their visibility cannot be reduced.

b) Inside static methods super cannot be used. But inside non static method you can use super to call a static super class method.

c) static methods are inherited.

d) if a class has defined a static method or has an inherited a static method, then a nonstatic method with same name in the that class is not possible.