Page 10 - ComputerScience_Class_11
P. 10
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 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. Static definitions as class variables and class
methods are 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.
10. Arrays, Strings
Structured data types – arrays (single and multi- dimensional), Strings. Example algorithms that use
structured data types (searching, finding maximum/minimum, sorting techniques, solving systems of
linear equations, substring, concatenation, length, access to char in string, etc.).
Storing many data elements of the same type requires structured data types – like arrays. Access in
arrays is constant time and does not depend on the number of elements. Sorting techniques (bubble,
selection, insertion), Structured data types can be defined by classes – String. Introduce the Java library
String class and the basic operations on strings (accessing individual characters, various substring
operations, concatenation, replacement, index of operations).
11. Basic input/output Text File Handling
(a) Basic input/output using Scanner class.
Input/output exceptions. Tokens in an input stream, concept of whitespace, extracting tokens from
an input stream (String Tokenizer class). The Scanner class can be used for input of various types of
data (e.g. int, float, char etc.) from the standard input stream.
Discuss the concept of a token (a delimited continuous stream of characters that is meaningful in
the application program – e.g. words in a sentence where the delimiter is the blank character). This
naturally leads to the idea of delimiters and in particular whitespace and user defined characters
as delimiters. As an example show how the StringTokenizer class allows one to extract a sequence
of tokens from a string with user defined delimiters.
(b) Data File Handling.
Need for Data file, Input Stream, Output Stream, Character Stream (FileReader, FileWriter),
Operations- Creation, Reading, Writing, Appending, and Searching.

