0% found this document useful (0 votes)
31 views5 pages

Exam Tips

1. The document provides tips for scoring well in sections A and B of a Java programming exam that lasts 90 minutes total. 2. Section A lasts 25 minutes and focuses on conceptual questions. Tips include writing clear multi-step differences, understanding empty for loops and if statements, and using proper terminology. 3. Section B lasts 15 minutes per program and involves coding programs. Tips include formatting code neatly, using the correct data types, following conventions for methods and loops, and testing edge cases.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views5 pages

Exam Tips

1. The document provides tips for scoring well in sections A and B of a Java programming exam that lasts 90 minutes total. 2. Section A lasts 25 minutes and focuses on conceptual questions. Tips include writing clear multi-step differences, understanding empty for loops and if statements, and using proper terminology. 3. Section B lasts 15 minutes per program and involves coding programs. Tips include formatting code neatly, using the correct data types, following conventions for methods and loops, and testing edge cases.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Tips to score in section A: (Time to be spent is 25mins)

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.

Slab based Programs:-


1) A taximeter follows the following method of billing:

Rs. 20 for the first kilometers,


Rs. 10 per km for next 5 kilometers,
Rs. 12 per km for next 10 kilometers,
Rs. 15 per km for above 16 kilometers. WAP to generate the bill of customer.  

 2) Write a java class to calculate and print the electricity bill to be paid by a


customer. Assume that the customer pays a rent of  Rs. 250.00 .

No. of units                                        Charge per unit


Upto 100 units                                       Rs. 1.50
For the next 100 units                           Rs. 2.00
For next 50 units                                   Rs. 2.50
Beyond 250 units                                   Rs. 4.00

3) WAP to accept the book name and number of days returned late to calculate
fine amt based on the given criteria:

No. of days Fine per day


First 5 days Rs.3
Next five days Rs.4
More than 10 days Rs.6

Range based Programs:-


1) WAp to compute the railway fare depending on the criteria as given
Age (in years) Distance (in kms) Fare (in Rupees)
Below 10 Rs. 5
Below 10 Between 10 and 50 Rs. 20
Above 50 Rs. 50
Below 10 Rs. 10
Between 10 and 60 Between 10 and 50 Rs. 40
Above 50 Rs. 80
Below 10 Rs. 4
Above 60 Between 10 and 50 Rs. 15
Above 50 Rs. 35

2) Digital World announces seasonal discount on the laptops in the given order.

Cost of the laptop                      Discount


Rs.20,000 -  Rs.30,000                       10%
Rs.30,000 – Rs.40,000                       15%
Rs.40,000 – Rs.50,000                       18%
> = Rs.50,000                                    20%
An additional discount of   5% on all types of laptops is given. Sales tax is
calculated at 12% on the price after the discounts. Define a class to accept the
cost of the laptop and print the amount payable by the customer on purchase.

You might also like