ICSE Theory Questions On BlueJ
ICSE Theory Questions On BlueJ
ICSE Theory Questions On BlueJ
Select a Topic
[11] Arrays
Introduction to a Java
[ICSE Syllabus on this Topic]
Not mention anything about this topic “Introduction to Java BlueJ
Environment”. but these questions are must be known by students.
Q. What is a bytecode?
Ans: Bytecode is a set of pseudo mechanic language instructions that are
understood by the JVM (Java Virtual Machine) and are independent of the
underlying hardware.
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’.
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 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 are literals? How many types of integer literals are available in
Java?
Ans: A literal is sequence of characters used in a program to represent a
constant value. 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. Different types of literals available in Java, they are: Integer literal,
Float literal, Boolean literal, Character literal, String literal and null literal.
Q. How many integer constants are allowed in Java? How are they written?
Ans: Java allows three types of integer constants: Octal (base 8), Decimal
(base 10), and Hexadecimal (base 16). 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.
1231. Floating point constants are fractional numbers (number with decimal
points). e.g. 14.2356
Q. Write the following real constants into fractional form: 0.113E04, 0.417E-
04, 0.4E-05, 0.123E02
Ans: 0.113E04 becomes 1130, 0.417E-04 becomes .0000417, 0.4E-05
becomes .000004, 0.123E02 becomes 12.3
Q. How many bytes occupied by the following data types: byte, short, int,
long, float, double, char, boolean.
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.
Q. What is the range of the following data types: byte, short, int, long, float,
double, char, boolean.
ICSE BLUEJ THEORY
Q. What is the largest and smallest value for floating point primitive data
types float?
Ans: The smallest value is -3.4E+38 and largest values is 3.4E+38 of floating
point data type.
Q. What do you mean by operator and write the name of all operators
given in your textbook.
Ans: The operations are represented by operators and the object of the
operations are referred to as operands. The types of Operators available in
ICSE BLUEJ THEORY
condition. This operator is also known as ternary operator. The syntax for
this operator is expression1?expression2:expression3
Q. What is operands?
Ans: An operator acts on different data items/entities called operands.
Q. What do you mean by type casting? What is the type cast operator?
Ans: The explicit conversion of an operand to a specific type is called type
casting. The operator that converts its operand to a specified type is called
the typecast operator. The typecast operator is ( ) in Java and is used as
(type-to-be-converted-in)
Constructor
ICSE BLUEJ THEORY
Q. What is constructor?
Ans: A constructor is a Member function that automatically called, when the
object is created of that class. It has the same name as that of the class
name and its primary job is to initialise the object to a legal value for the
class.
Parameterised constructor.
Example:
public class result
{
int per;
int tot;
public result (int percentage)
{
per=percentage;
tot=0;
}
}
Functions
[ICSE Syllabus on this Topic “Functions”]
User Define Functions as a way to define operations/methods/messages.
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. Variable of a class
type as reference to an objects, invocation of function on objects through
the reference, the concept of this. Argument passing in functions, pass by
value, what happened when a reference is passed side effect.
tells the program about the type of the value returned by the function and
the number and types of arguments.
{
return (length*breadth);
}
float area (float side1, float side2, float side3) //area of triangle
{
float s = (side1 + side2 + side3)/2;
float ar = Math.sqrt(s * (s- side1)*(s-side2) *(s-side3));
return (ar);
}
Q. What is the difference between primitive data types and composite data
types?
Ans: (i) primitive data types are built-in data types. Java provides these data
types. User-defined data types are created by users. (ii) The size of primitive
data types are fixed. The size of user-defined data types are variable. (iii)
Primitive data types are available in all parts of Java programs. The
availability of user-defined data types depends upon their scope.
Q. How are protected members different from public and private members
of a class.
Ans: Protected members of a class are accessible in all the classes in the
same package and subclass in the other packages. private members of a
class accessible in the member functions in the class only. Where as public
members are accessible globally.
Decision Making
[ICSE Syllabus on this Topic]
Application of if-then, if-then-else, switch (default, break).
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.
statements sequence associated with that case is executed until the break
statement or the end of switch statement is reached.
Iteration
[ICSE Syllabus on this Topic]
Utilization of loops. Fixed number of Iteration. The for Loop, unknown number of
Iteration – while, do-while loop, continue, break. Nested Loops.
Q. What are iteration statements? Name the iteration statements provided
by Java?
Ans: Iteration statements are statements that allows a set of instructions to
ICSE BLUEJ THEORY
Q. State one similarity and one difference between while and do-while loop.
Ans: Similarity: In both loops there is a chances to forget the increment
statement inside the 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.
repeated for defined number of times. Variable iterative loop repeats the
process till a given condition is true.
Q. What is an Exception?
Ans: Exception in general refers to some contradictory or unusual situation
which can be encountered while executing a program.
Q. What do you mean by try block? How do you define it, give an example.
Ans: The try block is the one that contains the code that is to be monitored
for the occurrence of an exception. A try block is defined by enclosing the
statements that might possible raise an exception in. For example if the
formatting exception are to be handled while an integer is being read from
the keyboard, then the following try block can be used:
int inData;
BufferedReader br=new BufferedReader( new
InputStreamReader(System.in));
try
{
inData=Integer.parseInt(br.readLine());
}
Q. What do you mean by catch block? How do you define it, give an
example.
Ans: The catch block is the one that contains the code handle an exception.
It must follow the try block. i.e. there should be no statement between the
try and the catch blocks. If the catch block is written for the above try block
then we may do it as follows:
int inData;
BufferedReader br=new BufferedReader( new
InputStreamReader(System.in));
try
{
ICSE BLUEJ THEORY
inData=Integer.parseInt(br.readLine());
}
catch(NumberFormatException nfEx)
{
System.out.println(“Input format is incorrect”);
}
Q. Define String?
Ans: A string is a set of two or more then two characters, a set of characters
ICSE BLUEJ THEORY
with the digit or a statement written with in double quotes. e.g. “Happy
New Year”, “Computer Application” etc.
Trim(): This function is used to remove all the white spaces at the beginning
and end of string.
String n=”AMIT “;
n=n.trim();
System.out.println(n);
equals(): This function is used to compare two string and give true or false if
they are equal.
String s1=”AMIT”;
String s2=”amit”;
System.out.print(s1.equals(s2));
Length(): This function return the length characters present in the string.
String s=”AMITABH”;
System.out.print(s.length());
charAt(): This function return the nth character of the string.
String s=”AMITABH”;
System.out.print(s.charAt(2));
concat(): This function concatenate/join two strings.
String s1=”AMITABH “;
String s2=”BANERJEE”
System.out.print(s1.concat(s2));
substring(): This function returns the substring starting from the nth
character of the string.
String s=”AMITABH”;
System.out.print(s.substring(3));
This function also returns the substring starting from the mth character
upto the nth character without including the nth character of the string.
String s=”AMITABH”;
System.out.print(s.substring(2,4));
indexOf(): This function returns the position of the first occurrence a
character in the string.
String s=”AMITABH”;
System.out.print(s.indexOf(‘A’));
This function also returns the position of the character from the nth
position of the string.
String s=”AMITABH”;
System.out.print(s.indexOf(‘A’,2));
compareTo(): This function returns negative if first string is less then second
string, positive if greater and zero if equals.
ICSE BLUEJ THEORY
String s1=”AMIT”;
String s2=”SUMIT”
System.out.print(s1.compareTo(s2));
Encapsulation
[ICSE Syllabus on this Topic]
private, public, scope and visibility rules. packages and package level access.
Arrays
[ICSE Syllabus on this Topic]
Array and their usage, sorting algorithm – selection sort and bubble sort,
search in sorted array. The class objects compatible with all the class.
Q. 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. Array can be declared by the following
statements: int n[]=new int[10];
item to be searched for one by one while binary search searches for the
given item in a sorted array. The search segment reduces to half at every
successive stage.