Page 9 - Cs_withBlue_J_C11_Flipbook
P. 9

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.

                  6.     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.
                  7.     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
                       values – variables denoting objects are references to those objects. The assignment operator = is special.
                       The variable on the LHS of = denotes the memory location while the same variable on the RHS denotes the
                       contents of the location e.g. i=i+2.

                       Note: Library functions for solving expressions may be used as and when required.
                  8.     Statements, Scope
                       Statements; conditional (if, if else, if else if, switch case) ternary operator, looping (for, while, do while),
                       continue, break; grouping statements in blocks, scope and visibility of variables.
                       Describe the semantics of the conditional and looping statements in detail. Evaluation of the condition in
                       conditional statements.
                       Nesting of blocks. Variables with block scope, method scope, class scope. Visibility rules when variables
                       with the same name are defined in different scopes.
                  9.     Methods and Constructors

                       Methods and Constructors (as abstractions for complex user defined operations on objects), methods as
                       mechanisms for side effects; formal arguments and actual arguments in methods; different behaviour of
                       primitive and object arguments. Static methods and variables. The this operator. Examples of algorithmic
                       problem solving using methods (number problems, finding roots of algebraic equations etc.).
                       Methods are like complex operations where the object is implicitly the first argument. Operator this denotes
                       the current object. Methods typically return values. Illustrate the difference between primitive values and
                       object values as arguments (changes made inside methods persist after the call for object values). Static
                       definitions as class variables and class methods visible and shared by all instances. Need for static methods
                       and variables. Introduce the main method – needed to begin execution. Constructor as a special kind of
                       method; the new operator; multiple constructors with different argument structures; constructor returns
                       a reference to the object.
   4   5   6   7   8   9   10   11   12   13   14