ICSE Board Computer Application Syllabus (2012-2013)
[1] Elementary Concept of Objects and Classes, [2] Values and types, [3] Conditionals and non-nested loops, [4] Class as the Basis of all Computation, [5] Constructors, [6] Functions, [7] Class as a User Defined Type, [8] Iterations, [9] Using Library Classes, [10] Encapsulation, [11] Arrays, [12] Input/Output.
Showing posts with label Chapter 1. Show all posts
Showing posts with label Chapter 1. Show all posts

Tuesday, October 18, 2011

Chapter 1 Syllabus

Elementary Concept of Objects and Classes
Modeling entities and their behavior by objects, a class  as a specification for objects and as an object factory, computation as message passing/function calls between objects (many examples should be done to illustrate this). Objects encapsulate state (attributes) and have behavior (functions). Class as a user defined type.

A class may be regarded as a blueprint to create objects. It may be viewed as a factory that produces similar  objects. A class may also be considered as a new data type  created  by  the  user,  that has  its  own functionality. All the four features  of Object Oriented Programming should  be  defined  and  explained  using  real  life examples. Analyze  each  object  and  show  how  each  contains attributes  and  responds  to  certain  messages  or permits certain operations. Emphasize  that an object is an instance  of a  class. A single object  is  just  a  bundle  of  values,  one for each attribute in the class.

Values and Types
Tokens  and  its  types,  Primitive  types,  operations  on primitive values,  expressions, assignment  (assignment is also an expression).

Introduce the  primitive  types and  the  range  of values each represents. Discuss all the operations that can be done  with  primitive  types  namely  mathematical, relational  and  logical. Discuss  precedence  and associativity  of  operators.  Introduce  the  concept  of type casting.

Introduce  System.out.println  and  System.out.print, for simple output. Discuss  different  types  of  errors  occurring  during execution  and  compilation  of  the  program  (syntax errors, runtime errors and logical errors).


Conditionals and non-Nested Loops
Application of if  else, if else if ladder, switch-case (default, break). Fixed  number  of  iterations - the  for  loop.  Unknown number of iterations - while loop, do-while loop. The  conditional/ternary  operator  (?  :  )  should  be introduced at this point. Loops are  fundamental  to  computation and  their need should be shown by examples. Examples:  various  number  based  problems:  prime numbers,  composite  numbers,  perfect  numbers, Fibonacci numbers, etc.
 

Sunday, October 9, 2011

Conditionals and non-nested loops

Q. What is a statement?
Ans: Statements are the instructions given to the computer to perform any kind of action, as data movements, making decision or repeating action. Statements form the smallest executable unit and terminated with semi-colon.

Q. What are the three constructs that govern statement flow?
Ans: The three constructs that governs statement flow are: Sequence, Selection and Iteration constructs.

Q. What is a selection/conditional statement? Which selection statements does Java provides?
Ans: A selection statement is the one that is used to decide which statement should be execute next. This decision is based upon a test condition. The selection statements provided by Java are: if-else and switch. The conditional operator ?: can also be used to take simple decision.

Q. What is an 'if' statement? Explain with an example.
Ans: the 'if' statement helps in selecting one alternative out of the two. The execution of 'if' statement starts with the evaluation of condition. The 'if' statement therefore helps the programmer to test for the condition. General form of 'if' statement.  if(expression) statementif(marks>=80)  System.out.println("Grade A");

Q. What is the significance of a test-condition in a if statement?
Ans: It is the test condition of an if statement that decides whether the code associated with the if part or the one associated with the else part should be executed. The former is executed if the test condition evaluates to true and the latter works if the condition evaluates to false.

Q. Write one advantage and one disadvantage of using ?: in place of an if.
Ans: Advantage: It leads to a more compact program. Disadvantage: Nested ?: becomes difficult to understand or manage.

Q. What do you understand by nested 'if' statements?    
OR
Q. Explain with an example the if-else-if construct.
Ans: A nested 'if' is an statement that has another 'if' in its body or in it's appearance. It takes the following general form.
if(ch>='A')
{
  if(ch<='Z')
    ++upcase;
  else
    ++other;
}

Q. What is the problem of dangling-else? When does it arise? What is the default dangling-else matching and how it be overridden?
Ans: The nested if-else statement introduces a source of potential ambiguity referred to as dangling-else problem. This problem arises when in a nested if statement, number of if's is more then the number of else clause. The question then arises, with which if does the additional else clause property match. For Exampleif(ch>='A')  if(ch<='Z')    ++upcase;else  ++other;The indentation in the above code fragment indicates that programmer wants the else to be with the outer if. However Java matches an else with the preceding unmatched if. One method for over-riding the default dangling-else matching is to place the last occurring unmatched if in a compound statement, as it is shown below.if(ch>='A'){  if(ch<='Z')    ++upcase;}else  ++other;

Q. Compare and contrast IF with ?:
Ans: (i) Compare to IF sequence, ?: offer more concise, clean and compact code, but it is less obvious as compared to IF. (ii) Another difference is that the conditional operator ?: produces an expression, and hence a single value can be assigned, for larger expression If is more flexible. (iii) When ?: operator is used in its nested form, it becomes complex and difficult to understand.

Q. What is a switch statement? How is a switch statement executed?
Ans: Switch statement successively tests the value of an expression against a set of integers or character constants. When a match is found, the statements associated with the constants are executed. The syntax  switch(expression){   case constants : statements; break;   case constants : statements; break;}The expression is evaluated and its values are matched against the value of the constants specified in the case statements. When a match is found, the statements sequence associated with that case is executed until the break statement or the end of switch statement is reached.

Q. What is the significance of break statement in a switch statement?
Ans: In switch statement when a match is found the statement sequence of that case is executed until a 'break' statement is found or the end of switch is reached, when a 'break' statement is found program execution jumps to the line of code following the switch statement.

Q. What is a control variable in a switch case?
Ans: A control variable in switch case is one which guides the control to jump on a specified case. e.g. switch(x), here 'x' is the control variable.

Q. What is a "fall through"?
Ans: The term "fall through" refers to the way the switch statement executes its various case sections. Every statement that follows the selected case section will be executed unless a break statement is encountered.

Q. What is the effect of absence of break in a switch statement?
Ans: Absence of break statement in a switch statement leads to situation called "fall through" where once a  matching case is found the subsequence case blocks are executed unconditionally

Q. Write one limitation and one advantage of switch statement?
Ans: Advantage: More efficient in case a value is to be tested against a set of constants. Disadvantage: switch can test only for quality, so for the rest of comparisons one needs to use if-else.

Q. Discuss when does an if statement prove more advantageous then switch statement.
Ans: In the following case if statement proves to be more advantage over switch statement: (i) When a range of values need to be tested for. (ii) When relation between multiple variables needs to be tested. (iii) When multiple conditions need to be tested. (iv) When expressions having a data type other then integer or character need to be tested.

Q. When does switch statement prove more advantageous over an if statement?
Ans: The switch statement is more advantageous then the if statement when the test expression whose data type is either of byte, short, character, integer or long is to be tested against a set of constants. The reason being that the switch statement evaluates the expression once whereas the equivalent if statement evaluates the expression repeatedly.

Q. Explain, with the help of an example, the purpose of default in a switch statement. [2005]
Ans: The default section is an optional part of the switch statement and the statement written under default clause are executed when no matching case is found.
switch(n)
{
  case 1: System.out.println("Sunday"); break;
  case 2: System.out.println("Monday"); break;
  case 3: System.out.println("Tuesday"); break;
  case 4: System.out.println("Wednesday"); break;
  case 5: System.out.println("Thursday"); break;
  case 6: System.out.println("Friday"); break;
  case 7: System.out.println("Saturday"); break;
  default :  System.out.println("Invalid Input");
}

Q. Differentiate between if and switch statements.
Ans: Both are used as a selection statements, there are some difference in their operations. (i) switch can only test for equality, where as if can evaluate a relational or logical expression. (ii) it statement can handle ranges , where as switch case level must be a single value. (iii) if statement can handle floating point test also, where as the switch case labels must be an integer or character.

Friday, October 7, 2011

Elementary Concepts of Object & Class

Q. What is an Object?
Ans: An Object is an identifiable entity with some characteristics and behavior. E.g. take a class 'Car'. A car class has characteristics like colour, gears, power, length etc. now we create the object of that class 'Car' namely 'Indica'.

Q. What is OOP? What are the features/concepts in OOP's?
OR
Name any two OOP'S principles.
Ans: The Object Oriented Programming Paradigm is the latest in the software development and the most adopted one in the programming development. The Paradigm means organising principle of a program. It is an approach to programming. The concepts of OOP's are: (1) Data Abstraction (2) Data Encapsulation (3) Modularity (4) Inheritance (5) Polymorphism.

Q. Explain all the Concepts of OOP's?
Ans: Abstraction: It refers to the act of representing essential features without including the background details or explanation. Encapsulation: It is the way of combining both data and the function that operates on the data under a single unit. Modularity: It is the property of a system that has been decomposed into a set of cohesive and loosely couple modules. Inheritance: It is the capability of one class of thing to inherit properties from another class. Polymorphism: It is the ability for a message or data to be processed in more than one form.

Q. What are the advantages of OOP's?
Ans: (1) Elimination of redundant coding system and usage of existing classes through inheritance. (2) Program can be developed by sharing existing modules. (3) Possibilities of multiple instance of an objects without any interference. (4) Security of data values from other segment of the program through data hiding.

Q. What is Class? How Object is related to the Class?
Ans: A Class represent a set of Objects that share common characteristics and behavior. Objects are instance of a class. The Object represents the abstraction representation by the class in the real sense.

Q. What is the need of a class in Java?
Ans: Classes in Java are needed to represent real-world entities, which have data type properties. Classes provide convenient methods for packing together a group of logical related data items and functions that work on them. In java the data items are called fields & the functions are called methods.

Q. What are Methods? How are these related to an Objects?
Ans: A Method is an operation associated to an Object. The behavior of an Object is represented through associated function, which are called Methods.

Q. Point out the differences between Procedural Programming and Object Oriented Programming.
Ans: Procedural programming aims more at procedures. The emphasis is a doing things rather then the data being used. In procedural Programming parading data are shared among all the functions participating thereby risking data safety and security. Object Oriented Programming is based on principles of data hiding, abstraction, inheritance and polymorphism. It implements programs using classes and objects, In OOP's data and procedure both given equal importance. Data and functions are encapsulated to ensure data safety and security.

Q. What is an abstraction?
Ans: An abstraction is a named collection of attributes and behaviors required to represent an entity or concept for some particular problem domain.

Q. What is inheritance and how it is useful in Java.
Ans: It is process by which objects of one class acquire the properties of objects of another class. Inheritance supports the concepts of hierarchical representation. In OOP the concepts of inheritance provides the idea of reusability.

Q. What role does polymorphism play as java feature?
Ans: It mean the ability to take more than one form. For example, an operation, many types of data used in the operation.

Q. What is Data hiding?
Ans: Data Hiding means restricting the accessibility of data associated with an object in such a way that it can be used only through the member methods of the object.

Q. What are nested classes?
Ans: It is possible to define a class within another class, such classes are known as nested classes. A nested class has access to the members including private members of the class in which it is nested. However the enclosing class not have access to the members of the nested class.

Q. Differentiate between base and derived class.
Ans: BASE CLASS - A class from which another class inherits (Also called SUPER CLASS)DERIVED CLASS - A class inheriting properties from another class. (Also called SUB CLASS)