Exam Tips
Exam Tips
1. When you write differences for 2 marks write 2 different points (number
the points, do not combine both the points as one paragraph.)
2. When the for loop ends with the semicolon, it is an empty loop.
3. If an if statement is terminated by semicolon, then it indicates there is no
true block statement.
a. int a=10;
if(a>=100);
System.out.println(“Executes”);//not considered as true block
4. While writing the output, write the dry run and write the answer i.e exact
output within a box.
5. The default value of any reference data type is null reference and char
data type is null character. The default value for boolean is false.
6. The ASCII values for uppercase alphabets is 65 to 90, the lowercase
alphabets is 97-122, space is 32 and for digits(0-9) is 48-57.
7. Learn the definition of autoboxing, unboxing, principles of OOPs,
accumulator, counter, etc.
8. All the Math functions except max, min, abs and round returns double.
Math.round returns int/long.
9. Learn the default values of all the data types, return type of all the
methods, purpose of System.exit().
10.Package that has the definition of
i. Scanner class is util
ii. Math, String, System is lang
11.Use technical and appropriate terminologies for the definitions. Refer the
notes shared to you earlier. Learn the purpose of all the java
keywords(final, new,break, continue).
(section B):
(Time to be spent for each program is 15mins. Try attending additional program
if possible)
1. Curly brackets can be ignored, if the block contains only one statement in
either loop block OR true block in if stmts.
eg for(i=1;i<=10;i++)
{ SOP(i);} // curly bracket is optional
2. Write the programs legibly and neatly.Dont write programs using pencil.
Leave lines between the statements so that any statement missed out can
be added later while checking the code. Do not use arrows or * to mark
that it is continued elsewhere
3. Write variable description for all the programs immediately after the
particular program. The data type, variable and the purpose should be
written in tabular form. Don’t write the variable description at the end of all
the programs.
4. String comparison –don’t use = = use equals method OR compareTo. Also
while sorting strings, don’t use > or < in sorting a string array.
5. a. length if a is an array and a. length() if a is a string.
6. If an individual character in a string has to be replaced with capitals, use
s1=s1+Character.toUpperCase(ch) [ ch.toUpperCase() is wrong]
7. Always create an array before accepting/assigning the values. [Just by
giving int[] a array is not created. int[] a=new int[n] creates the array.]
8. All the input parameters in the method definition should be preceded by
the data type.
9. Decide and use the most appropriate data type for the variables. [E.g.
x x x x
+ + + …….n , Here n should be int and x should be double and sum
3 6 9 12
should also be double.]
10.Don’t forget to write the code to display the menu(carries 1 mark) for
menu driven program and use only switch for the same(default is
compulsory).
11.Initialization of a float variable should be prefixed with ‘f’. Don’t forget to
initialize the result variable if it is used within a block as well as outside
the block. Like, in sum of series programs sum is calculated inside the loop
block and is printed outside the loop block.
12.When you accept a character use char ch=(char)sc.next().charAt(0);
13.Don’t give same name to the class and method name, except for
constructor.
14.Integer division gives integer result ( area = ½ * b* h gives zero)
15.For sorting characters in a String, use the following logic:-
String s1= “”;
for(char ch= ‘A’;ch<= ‘Z’;ch++)
for(int i=0;i<s.length();i++)
{
char ch1=s.charAt(i);
if(ch==ch1 || ch1==(char)(ch+32)) s1 = s1+ch1;
}
16. Write the output statement with appropriate message. If the format of the
output display is given, then follow the same format.
17.If a program is to check if it is palindrome or not, don’t forget to give a
display that the number is not a palindrome in the else clause.
18. Don’t try to return two values using return statement. (For example:-
return x,y OR return x;return y(in the same function) is invalid)
19. Write the function call statement as per the return type. If it is a void
method, call using its method name. for example:-
void fuction(int a)
{…
……}
The method call statement is function(x) where x is an int.
int function( int m)
{ int k = 1;
…..
…..
return k;
}
The method call statement is:-
int res =function(x);
20. Function prototype refers to the function header(first line) and function
definition refers to the complete function. For example
int fact(int a) function prototype
{ int f=1;
for(int i=1;i<=a;i++)
f=f*I;
return f;}
The above complete coding refers to the function definition. The
function call statement in the main() is
int res=fact(25);
21. Analyse the program to check for if it is slab based OR Range based
programs.
3) WAP to accept the book name and number of days returned late to calculate
fine amt based on the given criteria:
2) Digital World announces seasonal discount on the laptops in the given order.