Page 8 - computer science (868) class 11
P. 8

3.   Introduction to Object Oriented Programming using Java
                    Note that topics 5 to 12 should be introduced almost simultaneously along with Classes and their
                    definitions.

                 4.  Objects
                     (a)  Objects as data (attributes) + behaviour (methods or methods); object as an instance of a class.
                         Difference between object and class should be made very clear. BlueJ (www.bluej.org) and Greenfoot

                         (www.greenfoot.org) can be used for this purpose.
                     (b)  Analysis of some real-world programming examples in terms of objects and classes.
                         Use simple examples like a calculator, date, number etc. to illustrate how they can be treated as objects
                         that behave in certain well- defined ways and how the interface provides a way to access behaviour.
                         Illustrate  behaviour changes by adding  new methods, deleting old  methods or modifying  existing
                         methods.

                     (c)   Basic concept of a virtual machine; Java Virtual Machine (JVM); compilation and execution of Java
                         programs (the javac and Java programs).
                         The JVM is a machine but built as a program and not through hardware. Therefore it is called a virtual

                         machine. To run, JVM machine language programs require an interpreter. The advantage is that such
                         JVM machine language programs (.class files) are portable and can run on any machine that has the
                         Java program.
                     (d)   Compile time and run time errors; basic concept of an exception, the Exception class, try-catch, throw,
                         throws and finally.

                           Differentiate between compile time and run time errors. Run time errors crash the program. Recovery
                         is possible by the use of exceptions. Explain how an exception object is created and passed up until
                         a matching catch is found. This behaviour is different from the one where a value is returned by a
                         deeply nested method call.
                 5.     Primitive values, Wrapper classes, Types and casting

                      Primitive values and types: byte, int, short, long, float, double, boolean, char. Corresponding wrapper
                      classes for each primitive type. Class as type of the object. Class as mechanism for user defined types.
                      Changing types through user defined casting and automatic type coercion for some primitive types.
                      Ideally, everything should be a class; primitive types are defined for efficiency reasons; each primitive
                      type has a corresponding wrapper class. Classes as user defined types. In some cases types are changed
                      by automatic coercion or casting – e.g. mixed type expressions. However, casting in general is not a good
                      idea and should be avoided, if possible.

                 6.     Variables, Expressions
                      Variables  as  names  for  values;  named  constants  (final),  expressions  (arithmetic  and  logical)  and  their
                      evaluation  (operators,  associativity,  precedence).  Assignment  operation;  difference  between  left-hand
                      side and right-hand side of assignment.

                      Variables denote values; variables are already defined as attributes in classes; variables have types that
                      constrain the values it can denote. Difference between variables denoting primitive values and object
   3   4   5   6   7   8   9   10   11   12   13