Search for notes by fellow students, in your own course and all over the country.

Browse our notes for titles which look like what you need, you can preview any of the notes via a sample of the contents. After you're happy these are the notes you're after simply pop them into your shopping cart.

My Basket

You have nothing in your shopping cart yet.

Title: ICSE BlueJ Theory
Description: All BlueJ and Java related notes for ICSE students

Document Preview

Extracts from the notes are below, to see the PDF you'll receive please use the links above


4/20/2016

ICSE BlueJ Theory

Theory Questions on BlueJ/Java
(Note: Questions are collected from different ICSE Text Books, Question BANK and Specimen Paper
...
 (*) marks Questions are may not be so important
according to ICSE Syllabus or ICSE Exam point of view)
...
 but these questions are must be known by students
...
 Why is Java often termed as a platform?
Ans: Platform is the environment in which programs execute
...

Q
...

Q
...
 It hides the underlying OS from Java application
...
 Actually this Java interpreter is known as Java Virtual Machine (JVM)
...
 What is JDK (Java Development Kit)?
Ans: The Java development kit comes with a collection of tools that are used for developing and
running java programs
...
 What are Java APIs?
Ans: The Java APIs (Application Program Interface) consist of libraries of pre­compiled code
that programmers can use in their application
...
 Write the five characteristics of Java/BlueJ?
Ans: 1
...
 Light weight code 3
...
 Built in Graphics 5
...
 Support Multimedia 7
...
 8
...

Q
...
 It is an IDE (Integrated Development
Environment), which includes an editor a debugger and a viewer
...
 How you create, compile and execute a program in Java or BlueJ? Explain your answer?
Ans: Create: Click on new class button from BlueJ editor, then type the class name a program
icon will be created
...
org
...
htm#Arrays

1/25

4/20/2016

ICSE BlueJ Theory

your program coding
...
 Execute: Right click on the class
icon and select new class name option
...
 A
object icon will be created at the bottom
...

Q
...

Q
...

(ii) Java does not use pointers
...

(iv) Java does not have template classes as in C++
...
 State the differences between Syntax errors and Logical errors
...
 Syntax refers to
the structure of your program and the rules about that structure
...
 In Java, run­time errors occur when the interpreter is running the byte
code and something goes wrong
...
 "Object is an instance of a class", explain
Ans: Object of a class contains data and functions provided in a class
...
 Hence object is termed as instance of a class
...
 Name four basic features of JAVA
...

ii) Java program is both compiled and interpreted
...

iv) java is case sensitive language, i
...
 it distinguished upper and lower case letters
...
 Differentiate between Compiler and Interpreter
...
 Interpreter converts
program from high level language to machine level language line by line or statement by
statement
...
 Java uses compiler as well as interpreter, explain
...
 This byte code is further converted
into machine code to make it applicable for the specific platform by using interpreter
...
 Differentiate between Source code and Byte code
...
 Compiler converts source code to byte code for interpretation
...
 Differentiate between Testing and Debugging
...
 Debugging is the process of removing errors from a program
...
 A class as a specification of objects and as an
object factory, computation as message passing/function call between objects (many example
should be done to illustrate this)
...
 Class as a user defined type
...
 What is an Object? [2006]
Ans: An Object is an identifiable entity with some characteristics and behavior
...
g
...
 A car class has characteristics like colour, gears, power, length etc
...
org
...
htm#Arrays

2/25

4/20/2016

ICSE BlueJ Theory

object of that class 'Car' namely 'Indica'
...
 What is OOP? What are the features/concepts in OOP's? [2007]
                  OR
Name any two OOP'S principles
...
 The Paradigm means organising
principle of a program
...
 The concepts of OOP's are: (1) Data
Abstraction (2) Data Encapsulation (3) Modularity (4) Inheritance (5) Polymorphism
...
 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
...
 Modularity: It is the property of a system
that has been decomposed into a set of cohesive and loosely couple modules
...
 Polymorphism: It is
the ability for a message or data to be processed in more then one form
...
 What are the advantages of OOP's?
Ans: (1) Elimination of redundant coding system and usage of existing classes through
inheritance
...
 (3) Possibilities of
multiple instance of an objects without any interference
...

Q
...
 Objects
are instance of a class
...

Q
...
 Classes provide convenient methods for packing together a group of logical related
data items and functions that work on them
...

Q
...
 The behavior of an Object is represented
through associated function, which are called Methods
...
 Point out the differences between Procedural Programming and Object Oriented Programming
...
 The emphasis is a doing things rather
then the data being used
...
 Object Oriented Programming is
based on principles of data hiding, abstraction, inheritance and polymorphism
...

Data and functions are encapsulated to ensure data safety and security
...
 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
...
 What is inheritance and how it is useful in Java
...
 Inheritance supports the concepts of hierarchical representation
...

Q
...
 For example, an operation, many types of
data used in the operation
...
 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
...
 What are nested classes?
http://amitabhsirkiclasses
...
in/materials/icse/jtheory
...
 A nested class has access to the members including private members of the class in
which it is nested
...

Q
...
 [2008]
Ans: BASE CLASS ­ A class from which another class inherits (Also called SUPER CLASS)
DERIVED CLASS ­ A class inheriting properties from another class
...
 Variable define states, Member functions/operation/methods/messages defines
behaviors
...
 Variable declaration for both types, difference
between the two types
...
 Modeling by composition
...
 What are keywords? can keywords be used as a identifiers?
Ans: Keywords are the words that convey a special meaning to the language compiler
...

Q
...
g
...
 The identifiers in Java
...

(ii) Must not start with a digit
...

(iv) Can have any length and are case­sensitive
...
 Why keyword is different from identifiers?
Ans: Keywords are predefine sets of words that have a special meaning for the Java compiler
...

Q
...
[2008]
Ans: The smallest individual unit of a program is known as Token
...

Identifiers are names given to different parts of a program e
...
 variables, functions, classes etc
...

Q
...
 For
example 'A' is a literal that represents the value A of type char, and 17L is a literal that
represents the number 17 as value of type long
...

Q
...

Ans: Integer constants are whole numbers without any decimal part
...
 It may contains + or ­ sign
...

Q
...
g
...
 Those
nongraphic character can be represented by escape sequence
...
 The few escape sequence
characters are: \n for new line, \t for Horizontal Tab, \v for Vertical Tab, \b for Backspace, \"
http://amitabhsirkiclasses
...
in/materials/icse/jtheory
...

Q
...
 An Octal integer must be started with a zero '0', a Hexadecimal integer
starts with a '0X', all others are treated as decimal integer constant
...
 What is meant by a floating constant in Java? How many ways can a floating constant be represented
into?
Ans: Floating constants are real numbers
...

Q
...

Ans: Integer constants are the whole numbers (without decimal points)
...
g
...
 Floating
point constants are fractional numbers (number with decimal points)
...
g
...
2356
Q
...
113E04, 0
...
4E­05, 0
...
113E04 becomes 1130, 0
...
0000417, 0
...
000004,
0
...
3
Q
...
 When we specify that a variable has
certain type, we are saying what values the expression can have
...

Q
...

Ans: Primitive data types are those that are not composed of other data types
...

Q
...
 The primitive data types are: byte, short, int, long, float, double, char and Boolean
...

Q
...

Ans: The primitive data types are: byte, short, int, long, float, double, char and Boolean
...

Q
...

Ans: char­2 byte, byte­1 byte, short­2 bytes, int­4 bytes, long­8 bytes, float­4 bytes, double­8
bytes, boolean­Java reserve 8 bits but only use 1 bit
...
 What is the range of the following data types: byte, short, int, long, float, double, char, boolean
...
4x10 38 to 3
...
7x10 308 to 1
...
 What is the largest and smallest value for floating point primitive data types float?
Ans: The smallest value is ­3
...
4E+38 of floating point data type
...
 What is Token? What are the tokens available in Java? [2008]
Ans: The smallest individual unit of  a program is known as Token
...

Q
...

E
...
 double p;
http://amitabhsirkiclasses
...
in/materials/icse/jtheory
...
 What do you mean by variables? What do you mean by dynamic initialization of a variable?
Ans: A variable is a named memory location, which holds a data value of a particular data types
...
 example double p=Math
...
 What is the function of an operator?
Ans: Operators are special symbols that represent operations that can be carried out on
variables, constants or expressions
...
 What do you mean by operator and write the name of all operators given in your textbook
...
 The types of Operators available in Java are: 1
...

Increment/Decrement 3
...
 Logical 5
...
 Bitwise 7
...
 Conditional 9
...
 new operator 11
...
 () operator
...
 dot operator
...
 What are arithmetic operators?
Ans: Arithmetical operators are used for various mathematical calculations
...
 Arithmetical operators are of following types:
Unary and Binary operators
...
 Write major difference between the unary and binary operators?
Ans: The operators that acts on one operand are referred to as Unary Operator
...
 The operators that acts upon two
operands are referred to as Binary Operator
...

Q
...
 The increment operators add 1 to its
operand
...
g
...
g
...
 Find the value of x after evaluating x += x++ + ­­x + 4 where x=3 before the evaluation
...

Ans: Result is 13, because x++ is 3, ­­x is 2 + 4 the answer is 9 add this with x that is 3 it
becomes 12 and due to pre increment of x++ the result becomes 13
...
 What do you mean by Relational Operators
...

These are used in work of compression also
...
 < (less then), > (greater then), <= (less
then equals to), >= (greater then equals to), == (equals to), != (not equals to)
...
 What is Logical operators?
Ans: The logical operators combine the result of or more then two expressions
...
 The logical expression returns 1 if the result is true otherwise 0 returns
...

Q
...
 It takes the value on the right and stores
it in the variable on the left side
...
 What do you mean by Shift operators? OR Differentiate between Shift LEFT and Shift RIGHT operators
...
 The shift operators available in Java are:
(1)   >>     shift bits of right by distance
...
   (signed shifting)
(3)   >>>   shift bits of right by distance  (unsigned shifting)
Q
...

Ans: Shift LEFT (<<) operatr shifts the bit pattern of the operand towards left by defined
number of bits
...

e
...
 13>>2   is 3
http://amitabhsirkiclasses
...
in/materials/icse/jtheory
...
 Similarly LEFT shift (<<) operator is
also work
...
 What do you mean by Bitwise operators?
Ans: The Bitwise operations are performed by Bitwise operator
...

(a) The AND operator &
(b) The OR operator |
(c) The XOR operator ^
(d) The compliment operator ~
Q
...
 This operator is
also known as ternary operator
...
 and the example is  bonus=sales>15000?250:50;
Q
...
 
Ex
...
 What do you mean by precedence? Illustrate with the help of example
...
 All operators have precedence value
...
 consider the following
example 
  x = 5 + 4 *6;
The value of this expression is 29 not 54 or 34
...

Q
...

Q
...

Ans: The memory variables/locations whose values can not be changed within the program is
called constants
...

Q
...
lang
...
 Write down the equivalent expression for the mathematical expression   (a) (cos x/tan ­1 x)+x    (b) |ex ­
x|
Ans: (Math
...
atan(x)) + x      and   Math
...
exp(x)­x)
Q
...
ceil() and Math
...

Ans: Math
...
 e
...
 Math
...
85) gives output 13 and Math
...
35) also gives output 13
...
rint() returns the roundup nearest integer value
...
g
...
rint(12
...
rint(12
...

Q
...

Ans: The process of converting one predefined type into another is called Type Conversion
...
 The Java compiler
converts all operands up to the type of the largest operand
...
 e
...
 'c'­32  is converted to int type
...
 e
...

(float)(x+y/2)
Q
...
 A implicit type conversion
is a conversion performed by the compiler
...
 This is default type conversion
...
org
...
htm#Arrays

7/25

4/20/2016

ICSE BlueJ Theory

Q
...
 The operator
that converts its operand to a specified type is called the typecast operator
...
 Explain the methods print() and println()?
Ans: A computer program is written to manipulate a given set of data and to display or print the
results
...

print() method println() method
...
 This buffer is not flushed until a new line
(or end­of­line) character is sent
...

The println() method by contrast takes the information provided and displays it on a line
followed by a line feed
...
 What is an Expression? Explain its different types
...
 It may be combination of operators, variables and constants
...

(1) Constant Expressions: 8 * 12 /2
(2) Integral Expressions: formed by connecting integer constants x = (a + b)/2
(3) Logical Expressions: a > b    or a!=b
Q
...
 [2005]
Ans: The two ways of inserting a comments in a program are:
  (i) using //                     single line comments
  (ii) using /*     */           multiple line comments
Q
...
        [2005]
Ans: The operations are represented by operators and the object of the operations are referred
to as operands
...

Q
...
        [2005]
Ans: It is a block of code containing more then one executable statement
...
 The { } opening and closing braces indicates the start and end of a compound
statement
...
out
...
out
...
out
...
 Overloading constructor
...
 What is constructor?
Ans: A constructor is a Member function that automatically called, when the object is created of
that class
...

Q
...
org
...
htm#Arrays

8/25

4/20/2016

ICSE BlueJ Theory

Ans: Constructor is used create an instance of of a class, This can be also called creating an
object
...
 Why does a constructor should be define as public?
Ans: A constructor should be define in public section of a class, so that its objects can be created
in any function
...
 Explain default constructor? [2006]
Ans: The constructor that accepts no parameter is called the default constructor
...
, then java creates a default constructor for the class
...

Example:
  class ant
  {
    int i;
    public static void main()
    ant nc=new ant();
  }
the line new ant() creates an object and calls the default constructor, without it we have no
method to call to build our objects
...

Q
...
 Constructor
that can take arguments are called Parameterised constructor
...
 Give an syntax/example of constructor overloading
...
 Write constructor for the class, which accepts parameter to initialise the data member
...

Ans: class student
  {
    int roll;
    float marks;
    student(int r, float m)                 // constructor with two argument
...
 Mention some characteristics of constructors
...
org
...
htm#Arrays

9/25

4/20/2016

ICSE BlueJ Theory

Ans: The special characteristics of constructors are:
(i) Constructors should be declared in the public section of the class
...
 (iii) They do not have any return type and
cannot return any values
...
 (v) A class
can have more than one constructor
...
 (vii) If
no constructor is present in the class the compiler provides a default constructor
...
 State the difference between Constructor and Method
...
 but the constructor has no return type
...

Q
...
   [2005]
class swap
{
  int a,b;
  swap(int x,int y)
  {
    a=x;
    b=y;
  }
  public void main(String args[])
  {
    int t=a;
    a=b;
    b=t;
    System
...
out
...
 What are the types of Constructors used in a class?
Ans: The different types of constructors are as follows:
i
...

ii
...

iii
...

Q
...
 
Ans: A copy constructors initializes the instant variables of an object by copying the initial value
of the instant variables from another objects
...
g
...

  xyz(int x,int z)
  {
    a=x;
    b=y;
  }
  xyz(xyz p)
  {
    a=p
...

  }

 
 
 
 

User Define Functions
[ICSE Syllabus on this Topic]
http://amitabhsirkiclasses
...
in/materials/icse/jtheory
...
 Pure functions return values and do
not change state, impure functions may return values but also change state, return type
argument to function, function prototype and function signature, overloading
...
 Argument passing in functions, pass by value, what happened when a reference
is passed side effect
...
 What is Function? Why do we use functions while programs handling?
Ans: A named unit of a group of programs statements
...

Q
...

Q
...
 Thus a function that does not return a value is declared as
follows
...
 Explain Functions/Methods Definitions with syntax?
Ans: A function must be defined before it is used anywhere in the program
...
 [modifier] can be one of final,
native, synchronize, transient, volatile
...
 It may be any valid Java data type
...

Q
...
 hence as soon as the command
for execution of the program is used, control directly reaches the main() function
...
 Explain the function prototype and the signature?
Ans: The function prototype is the first line of the function definitions, that tells the program
about the type of the value returned by the function and the number and type of the
arguments
...

Q
...
 First an immediately exit from the function is
caused as soon as a return statement is encountered and the control back to the main caller
...

Q
...
 Difference between Actual argument and Formal argument? [2007,2008]
Ans: The parameter that appears in function call statement are called actual argument and The
parameter that appears in function definition are called formal parameter
...
 What are static members?
Ans: The members that are declared static is called static members
...

Q
...
 (ii) They can only access static data
...

http://amitabhsirkiclasses
...
in/materials/icse/jtheory
...
 What is call by value?   [2005]
Ans: (i) In call by value, the called functions creates its own work copy for the passed
parameters and copies the passed values in it
...

Q
...
 Any changes that take place
are reflected in the original data
...
 Differentiate between call by value and call by reference?
Ans: In call by value, the called functions creates its own work copy for the passed parameters
and copies the passed values in it
...
 In call by reference, the called function receives the reference to
the passed parameters and through this reference, it access the original data
...

Q
...
 The following functions is the example of an impure function: 
public static void increment(Time obj, double secs)
{
  time
...
 What is the difference between pure and impure functions? [2009]
Ans: Pure Function: These functions takes objects as an arguments but does not modify the
state of the objects
...
 Impure Function: These
functions change the state of the object arguments they have received
...
 How are following passed in Java?              [2005]
    (i) primitive types    (ii) reference types
Ans: (i) By value,     (ii) By reference
...
 What does function overloading mean? What is its significance?
Ans: A Function name having several definitions in the same scope that are differentiable by
the number or type of their arguments, is said to be an overloaded function
...

Q
...
  [2006]
Ans:­ A function name having several definitions that are differentiable by the numbers or
types of their arguments is known as function overloading
...

float area (float radius)            //circle
{    
    return (3
...
sqrt(s * (s­ side1)*(s­side2) *(s­side3));
    return (ar);
}
Q
...
 The member functions of
every objects have access to a sort of magic keyword name this, which points to the object
http://amitabhsirkiclasses
...
in/materials/icse/jtheory
...
 Thus any member function can find out the address of the object of which it is a member
...
 it stores the address of
the object that invoking a member function and it is an implicit argument to the member
function being invoked
...

Q
...

Q
...


Class as a User Defined Types
[ICSE Syllabus on this Topic]
Class as a composite type, distinction between primitive type and composite of class type
...
 What is data type?
Ans: Data types are means to identify the type of data and associated operations of handling it
...
 What is composite (user define) data type? Explain with an example? [2007] [2009]
Ans: A composite datatype is that datatype that are based on fundamental or primitive
datatypes
...

class Date
{
  int dd, mm, yy;
  public Date()
  {
    dd=1;
    mm=1;
    yy=2005;
  }
}
Q
...

Q
...
 
Q
...
 Java provides these datatypes
...
 (ii) The size of primitive datatypes are fixed
...
 (iii) Primitive datatypes are available in all parts of Java
programs
...
 
Q
...
 But in order for a class to be user­defined
datatype, it should be act different from that of an application
...
e
...
 Although we can create instance of classes containing main method, they should
not be referred to as used­defined datatype
...

Q
...

[2008]
Ans: Access specifier can be of following types:
(a) PUBLIC: Public members of a class are globally accessible
...

(c) PROTECTED: Protected members of a class are accessible in the package where the class is
defined and in all the sub­classes of the class
...
org
...
htm#Arrays

13/25

4/20/2016

ICSE BlueJ Theory

(d) Default (friendly) access: members with default (friendly) access can be used within the
package where the class is defined
...
 How are private member different from public member of a class
...

Q
...

Ans: Protected members of a class are accessible in all the classes in the same package and
subclass in the other packages
...
 Where as public members are accessible globally
...
 Mention any two attributes required for class declaration
...
 Access Specifier  2
...
 Class Name

Decision Making
[ICSE Syllabus on this Topic]
Application of if­then, if­then­else, switch (default, break)
...
 What is a statement?
Ans: Statements are the instructions given t the computer to perform any kind of action, as data
movements, making decision or repeating action
...

Q
...

Q
...
 This decision is based upon a test condition
...
 The conditional operator ?: can also be used to take simple decision
...
 What is an 'if' statement? Explain with an example
...
 The execution of 'if'
statement starts with the evaluation of condition
...
 General form of 'if' statement
...
out
...
 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
...

Q
...

Ans: Advantage: It leads to a more compact program
...

Q
...
 Explain with an example the if­else­if construct
...
 It takes
the following general form
...
org
...
htm#Arrays

14/25

4/20/2016

ICSE BlueJ Theory

}
Q
...
 This problem arises when in a nested if statement, number of if's is
more then the number of else clause
...
 For Example
if(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
...
 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
...
 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
...
 (iii) When ?: operator is used in its nested form, it becomes complex and difficult to
understand
...
 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
...
 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
...

Q
...

Q
...
 e
...
 switch(x), here 'x' is the control variable
...
 What is a "fall through"?
Ans: The term "fall through" refers to the way the switch statement executes its various case
sections
...

Q
...
 Write one limitation and one advantage of switch statement?
http://amitabhsirkiclasses
...
in/materials/icse/jtheory
...

Disadvantage: switch can test only for quality, so for the rest of comparisons one needs to use
if­else
...
 Discuss when does an if statement prove more advantageous then switch statement
...
 (ii) When relation between multiple variables
needs to be tested
...
 (iv) When expressions
having a data type other then integer or character need to be tested
...
 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
...

Q
...
 [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
...
out
...
out
...
out
...
out
...
out
...
out
...
out
...
out
...
 Differentiate between if and switch statements
...
 (i)
switch can only test for equality, where as if can evaluate a relational or logical expression
...
 (iii) if
statement can handle floating point test also, where as the switch case labels must be an
integer or character
...
 Fixed number of Iteration
...
 Nested Loops
...
 What are iteration statements? Name the iteration statements provided by Java?
Ans: Iteration statements are statements that allows a set of instructions to be executed
repeatedly till some condition is satisfied
...

Q
...
 The differences between these two loops are: (1) In while loop the test expression is
evaluated at the beginning where as in do­while loop test expression is evaluated at the bottom,
after the body of the loop
...

Q
...
 [2005] [2008]
Ans: Both statements are used as a jumped statement
...
 The break statement terminate the loop, but the continue statement
skip the rest of the loop statement and continued the next iteration of the loop
...
g
...
org
...
htm#Arrays

16/25

4/20/2016

ICSE BlueJ Theory

{
  i++;
  if(i==5)
    break;
  System
...
println(i);
}
e
...
 of Continue Statement
int i=0;
while(i<=10)
{
  i++;
  if(i==5)
    continue;
  System
...
println(i);
}
Q
...
 (ii) The
while loop should be preferred if the number iteration is dependent upon some control variable
...

Q
...
 [2005]
Ans: In Java the 'for' statement is the most common iterative statement
...
 Three statement separated by
semi colons are placed with in the parenthesis
...
out
...
 State one similarity and one difference between while and do­while loop
...
 Difference: In while loop the test expression is evaluated at the beginning where as in do­
while loop test expression is evaluated at the bottom, after the body of the loop
...
 What do you meant by an infinite loop? Give an example
...
 What do you meant by an endless loop? Give an example
...

eg: for(;;)
     System
...
println("java");
Q
...

Ans: Fixed type of iterative loop is created when the process is to be repeated for defined
number oft imes
...

Q
...

Ans: A Null loop does not contains any statement to repeat where as infinite loop repeats
execution of the statements for endless iterations
...
g
...
g
...
 What do you mean by delay loop?
Ans: A null loop is also called delay loop which does not repeat the execution of any statement
but keeps the control engaged until the iterations are completed
...
org
...
htm#Arrays

17/25

4/20/2016

ICSE BlueJ Theory

Using Library Classes
[ICSE Syllabus on this Topic]
Simple input, output
...

Q
...
 What are the two ways of obtaining input in Java?
Ans: Bye oriented IO reads bytes of data or binary where there is no notation of datatypes
...
 In
Java byte oriented IO is performed through data streams where as character oriented IO is
performed through Readers and Writers
...
 What is an Exception?
Ans: Exception in general refers to some contradictory or unusual situation which can be
encountered while executing a program
...
 What is exception and what is exception handling? [2008]
Ans: During program development there may be some cases where the programmer does not
have the certainty that this code­fragment is going to work right, either because it accesses
resources that do not exist or it goes out of range
...

Q
...
 (ii) It clarifies the
code and enhanced readability
...
 (iv) It makes for clear, robust, fault tolerant programs
...
 When is Exception Handling required?
Ans: The exception handling is ideal for:
(i) Processing exceptional situations
...

(iii) Processing exceptions for widely used components that should not process their own
exception
...
 What do you mean by try block? How do you define it, give an example
...
 A try block is defined by enclosing the statements  that might possible raise an
exception in
...
in));
try
{
  inData=Integer
...
readLine());
}
Q
...

Ans: The catch block is the one that contains the code handle an exception
...
 i
...
 there should be no statement between the try and the catch blocks
...
in));
try
{
  inData=Integer
...
readLine());
}
catch(NumberFormatException nfEx)
{
  System
...
println("Input format is incorrect");
}
http://amitabhsirkiclasses
...
in/materials/icse/jtheory
...
 What is finally block? When and how it is used
...
 The code written in this block is
always executed irrespective of whether an exception was reported or not, or even if it was
handled successfully or not
...
g
...

Q
...

Ans: EOFException: Signals that an and of the file or end of the stream has been reached
unexpectedly during input
...

InterruptedIOException: Warns that an IO operation has been interrupted
...

Q
...
lang and these convert
primitive datatypes into an object
...
 Java provides the following wrapper classes: Boolean Integer,
Float, Double, Character etc
...
 Why do we need a wrapper class?
Ans: A wrapper class is needed to store primitive values in objects as well as in conversion from
string to to primitive type
...
 Distinguish between data type and wrapper class
...

Q
...
 e
...
 "Happy New Year", "Computer Application" etc
...
 What is String Buffer? How we create a String Buffer?
Ans: String Buffer is a type of memory location, which allows reasonable space to contain a
string such a way that any change brought affect the same string
...
 Differentiate between String and StringBuffer objects
...
e
...
 if any
change occurs in a String object, then original object string remains unchanged and a new
String is created with the changed String
...

That is these objects can be manipulated and modified as desired
...
 Write down the purpose of the following string functions: toLowerCase(), toUpperCase(), replace(), trim(),
equals(), length(), charAt(), concat(), substring(), indexOf(), compareTo()
...

for example:
String n="AMITABH";
n=n
...
out
...

for example:
String n="amitabh";
n=n
...
out
...

String n="DAD";
n=n
...
out
...

String n="AMIT    ";
n=n
...
org
...
htm#Arrays

19/25

4/20/2016

ICSE BlueJ Theory

System
...
println(n);
equals(): This function is used to compare two string and give true or false if they are equal
...
out
...
equals(s2));
length(): This function return the length characters present in the string
...
out
...
length());
charAt(): This function return the n th character of the string
...
out
...
charAt(2));
concat(): This function concatenate/join two strings
...
out
...
concat(s2));
substring(): This function returns the substring starting from the n th character of the string
...
out
...
substringt(3));
This function also returns the substring starting from the mth character upto the n th character
without including the n th character of the string
...
out
...
substringt(2,4));
indexOf(): This function returns the position of the first occurrence a character in the string
...
out
...
indexOf('A'));
This function also returns the position of the character from the nth position of the string
...
out
...
indexOf('A',2));
compareTo(): This function returns negative if first string is less then second string, positive if
greater and zero if equals
...
out
...
compareTo(s2));
Q
...

Q
...
 [2006]
Ans: Both the functions is used to comparing two strings, the difference being that (i) equals()
method only comparing two string and gives they are equal or not, where as compareTo()
methods also gives whether first string is greater or smaller then second one
...

Q
...
   [2005]
Ans: The given two string method's change the case of the current string
...

Q
...

Ans: The function length() returns the number of character contains in a string
...

Q
...
lang, utilities java
...
io, GUI java
...
applet, network services java
...

Q
...
org
...
htm#Arrays

20/25

4/20/2016

ICSE BlueJ Theory

Ans: The members that are declared static are called static members
...

Q
...

Q
...

(ii) They can only access static data
...

Q
...
 These
classes are divided into groups called packages
...
applet,
java
...
io, java
...
new, java
...

Q
...

Ans: In packages classes can be unique compared to other programs and be easily be reused
...
 What are Java API packages:
Ans: Java API packages provide a large number of class grouped into different packages
according to functionality
...
 What are system packages?
Ans: The packages which are organised in hierarchical structure are referred as system
packages
...
 Explain the method on importing a package member?
Ans: To import a member of package into the current file, put an import statement at the
beginning of the file before any class definitions but after the package statement, if there is one

...
 Describe the method to import entire package?
Ans: To import a member all the classes contained in a particular package, using the import
statement with the asterisk(*) wild card character
...
 Distinguish between Static variable (class variable) and member variable (instance variable)

(i) Declare with the static keyword
...

(iii) Created when class is first referred to
...

(v) Can be accessed using either the class name or name of any instance
of the class
...

(ii) Exist at
instance level i
...

can not be used if
there are no
instance of class
exist in memory
...

(iv) Destroyed
when the instance
containing  them is
destroyed
...


Q
...
 Give an Example
...

public class abc
{
  int a,b;     // instance variable or data member
}
http://amitabhsirkiclasses
...
in/materials/icse/jtheory
...
 State the difference between == operator and equals() method
...
 It is a relational operator
...
 it tests the value on the right side with value on the left
side
...
 It is a string function
...
 It compares two strings and gives the value as true or
false
...
 packages and package level access
...
 Explain the term 'Encapsulation' with an example? [2006]
Ans: The wrapping up to data and methods into a single units (called class) is known as
encapsulation
...
 Encapsulation property hides the inner working
of objects from the real world
...
 What does a class encapsulate?
Ans: A class encapsulate Data Members that contains the information necessary to represent
the class and Member Functions that perform operations on the data member
...
 How does a class enforce information hiding?
Ans: Classes enforce information hiding by means of access specifier
...
 What is initial class?
Ans: A java program contains many classes
...
 This class is called initial class
...
 What is Class variable (Static Variable)?
Ans: A data member that is declared once for a class
...
 Keyword 'Static' in the
variable declaration makes a class variable
...
 What is Instance variable? [2007] [2008]
Ans: A data member that is created for every objects of the class
...
 What does the class consists of ?
Ans: A class consists of:
(i) Data members: It contain information necessary to represent that class 
...

Q
...
 It defines which function or method is able to use this
method
...
 Define variable's scope (scope rule)?
Ans: The program parts in which a particular data value (e
...
, variable) can be accessed is
known as variable's scope
...
 Define the term visibility?
Ans: Visibility is a related term which refers to whether one can use a variable from a given
place in the program
...
 Define the term Local variable and Global variable
...

Global Variable: Class variable which is available to the entire class
...
 Mention the levels of scope and visibility offered by java?
Ans: (i) Data declared at the class level can be used by all methods in the class
...

(iii) Data declared within a method is called local data
...
e
...
org
...
htm#Arrays

22/25

4/20/2016

ICSE BlueJ Theory

the block
...

(vi) Variable declared in exterior blocks are visible to the interior blocks
...
 Explain the different types of access specifier?
Ans: Access specifier can be of following types:
(a) PUBLIC: It means that any one can call this method
...

(c) PROTECTED: It means that methods in this class and methods in any subclass may access
this method
...
 What are member variables? State their types?
Ans: Member variables are also known as Instance variables
...
 It may be public, private and protected, where private and protected
members remains hidden from outside world and there by support data
...
 What is meant by private visibility of a method? [2006]
Ans: PRIVATE visibility of a Method means that only the methods in the same class are
permitted to use this method
...
 The class objects compatible with all the class
...
 What do you understand by Arrays? How you declare an Array?
Ans: An Array is a collection of variables of the same data type that are referenced by a common
name
...
 What are the different types of arrays?
(i) Single Dimensional Arrays: A list of items can be given one variable name using only one
subscript and such a variable is called a single subscripted variable or a one or single
dimensional array
...

Q
...

Ans: The Advantages or Arrays are: (i) Easy to Specify
...
 (iii)
Random access of elements
...

Q
...

Q
...

Q
...
 The
Binary search requires the array must be sorted in any order
...
 If the ITEM is more then the middle element later part of the
arrays becomes the new array segment
...

Q
...
 The
search segment reduces to half at every successive stage
...
 State the conditions under which Binary Search is applicable?
Ans: For Binary Search The List must be sorted, lower bound upper bound and the sort order of
http://amitabhsirkiclasses
...
in/materials/icse/jtheory
...

Q
...
 If
the search item happens to be in the  beginning of the array, the compressions are low,
however if the element to be searched for is one of the last elements of the array, this search
technique proves the worst as so many comparisons take place
...
 This technique proves efficient in nearly all the cases
...
 What do you mean by sorting?
Ans: Sorting of an array means arranging the array elements in a specified order
...
 What is Selection sort?
Ans: In selection sort the smallest ( or largest depending upon the desired order) key from the
remaining unsorted array is searched for and put in the sorted array
...

Q
...
 This process is repeated until the entire array is sorted
...
 Which element is num[9] of the array num?        [2005]
Ans: 10th element
...
 So 9th
element is treated as the 10th element in an array
...
 token and String Tokenizer
and stream Tokenizer classes
...
 What is File?
Ans: A file is a means of making data persistent
...

Q
...

Q
...
 Stream are
object representation of this flowing data and are used by java to carry out data interchanged
in  a program
...
 What is the role of Input Stream class?
Ans: InputStream class provides the basis for classes used to read binary data from a file, a pipe
or an input device
...
 What is the role of a Reader class?
Ans: Reader class provides the basis for classes used to read character data from a file or an
input device
...
 What is the role of Output Stream class?
Ans: OutputStream class provides the basis for classes used to write binary data to a file, a pipe
or an output device
...
 What is the role of a Writer Class?
Ans: Writer class provides the basis for classes used to write character data to a file, a pipe or
an output device
...
org
...
htm#Arrays

24/25

4/20/2016

ICSE BlueJ Theory

Q
...

Ans: Classes for byte I/O are DataInputStream and DataOutputStream
...
 Can we open an existing file for writing? If not, why?
Ans: When an existing file is to be opened for writing all the data of the file is truncated unless
it is opened in the append mode using the following syntax:
  FileOutputStream file=new FileOutputStream("student
...
 What are Input and Output stream
...

Q
...

Q
...
 the buffer is then
accessed as needed and when emptied another chunk of data is read from the stream into the
buffer
...
 Once the buffer is
full, the data is sent to the stream all at once and the buffer is emptied to receive more data
...
 What is the String Tokenizer?
Ans: A String Tokenizer can identify and parse (segregate) token in a string
...
util package
...
 (i) countToken() (ii) nextToken()
Q
...
 When reading an input string supplied by a user we like to be able to
analyze it token by token
...
 We can
also use the string Tokenizer to process input from a file line by line
...
 What is the difference between Text file and Binary file?
Ans: In text file data are stored as per a specific character encoding scheme
...

Q
...
io package file?
Ans: The package java
...
 This package provides API that can be used to perform character/byte based data
input/output in Java program
...
org
...
htm#Arrays

25/25


Title: ICSE BlueJ Theory
Description: All BlueJ and Java related notes for ICSE students