Formatting page ...
COMPUTER APPLICATIONS STATISTICS AT A GLANCE Total Number of students who took the examination 86,618 Highest Marks Obtained 100 Lowest Marks Obtained 2 Mean Marks Obtained 80.9 Percentage of Candidates according to marks obtained Mark Range Details Number of Candidates Percentage of Candidates Cumulative Number Cumulative Percentage 0-20 4 0.00 4 0.00 21-40 132 0.15 136 0.16 41-60 9197 10.62 9333 10.77 61-80 30289 34.97 39622 45.74 81-100 46996 54.26 86618 100.00 Range of Marks Obtained 54.26 Percentage of Candidates 60.00 50.00 34.97 40.00 30.00 20.00 10.62 10.00 0.00 0.15 0.00 0-20 21-40 41-60 Marks Obtained 222 61-80 81-100 COMPUTER APPLICATIONS ANALYSIS OF PERFORMANCE Question 1 (a) What is meant by precedence of operators? [2] (b) What is a literal? [2] (c) State the Java concept that is implemented through: (i) a superclass and a subclass (ii) the act of representing essential features without including background details. (d) Give a difference between a constructor and a method. (e) What are the types of casting shown by the following examples? [2] [2] (i) double x = 15.2; int y = (int)x; (ii) int x = 12; long y = x; [2] Examiners Comments (a) Most candidates were unfamiliar with the term operator precedence. Some candidates wrote the types of operators, while a few mentioned the operators in order. (b) Most candidates answered this question correctly. (c) (i) Most candidates did not have a clear concept of the feature of object oriented programming that is implemented through super class and subclass. (ii) Candidates were able to answer the second part of the question correctly. (d) Most candidates answered correctly. In some answers, the difference between a constructor and a method was interchanged. (e) Some candidates were unsure of the answer. They seem to have overlooked the mention of (int)x in the question and mixed up the answers. 223 Suggestions for teachers - Explain how an expression is evaluated with examples and the relevant terms related to it. - Revise the previous year ( Class IX) syllabus (Java fundamentals) at the beginning of the session. - Explain the features of object oriented programming by referring to real life examples. - Teach differences between a constructor and method with the help of examples. - Explain each type of conversion with proper examples and point out the difference between them. MARKING SCHEME Question 1 (a) Operator precedence determines how an expression gets evaluated OR It is a set of rules that establishes which operators gets evaluated first and how operators with in the same precedence level associate. A literal is a sequence of characters used in a program to represent a constant value.OR A literal is a way of writing a value. For example A is a literal that represents the value A , of type char, and 15L is a literal that represents the number 15 as a value of type long (i) Inheritance (ii) Abstraction, Data Abstraction Any two of the following: Constructor Method Same name as the class Name is different from class name Has no return type Has a return type Invoked using new operator Invoked using dot operator Invoked when object is created Invoked at function call Specifies how object is created Specifies operations that objects perform (i) Explicit OR explicit conversion OR explicit type casting (ii) Implicit OR implicit conversion OR implicit type casting (b) (c) (d) (e) Question 2 (a) Name any two wrapper classes. [2] (b) What is the difference between a break statement and a continue statement when they occur in a loop? (c) [2] Write statements to show how finding the length of a character array char[] differs from finding the length of a String object str. (d) (e) [2] Name the Java keyword that: (i) indicates that a method has no return type (ii) stores the address of the currently - calling object. What is an exception? [2] [2] 224 Examiners Comments: Suggestions for teachers (a) Most candidates were able to answer this question Refrain from teaching all programs correctly. However, some candidates wrote the using Parameterized method. Explain names of primitive data type instead of writing the uses of wrapper class and its wrapper class. methods. (b) Most candidates explained the use of break Advise students to read questions statement with the help of an example. Some carefully and revise their work. candidates explained the use of break when it Highlight the difference between occurs in switch .case statement which was not break and continue statement with required as per the question. Only a few could examples. write the correct explanation and example for Advise students to read the question continue statement. carefully before answering. (c) Most candidates were unable to understand one Explain the use of key word this part of the question and wrote incorrect answers. with the help of example programs. (d) (i) Most candidates wrote correct answers. (ii) Many candidates answered this question correctly. A few candidates however wrote incorrect answers like new/pass by reference. (e) This question was correctly answered by most candidates. Some however were unclear as they wrote on exception handling and the keyword used to remove the exception. MARKING SCHEME Question - 2 (a) Any two of the following: Boolean, Byte, Character, Short, Integer, Long, Float, Double. Each must begin with upper case letter. (b) break Causes immediate exit from the loopORterminates loopOR resumes program execution at the statement immediately following the current statement. Continue Causes the remainder of the current iteration to be skippedOR resumes loop OR resumes program execution at the end of the current loop. (c) char.lengthOR length of character array is obtained from its length field. str.length()OR length of a String object is obtained from its length() method. (d) (i) void (ii) this (e) An error OR event that occurs during runtime OR during program execution, that prevents the program from continuing normally OR disrupts the normal flow of the program's instructions. Question 3 (a) Write a Java statement to create an object mp4 of class digital. (b) State the values stored in the variables str1 and str2 [2] String s1= "good"; String s2= "world matters"; String str1=s2.substring(5).replace('t', 'n'); String str2=s1.concat(str1); [2] 225 (c) What does a class encapsulate? [2] (d) Rewrite the following program segment using the if...else statement comm =(sale>15000) ? sale 5/100 : 0; (e) [2] How many times will the following loop execute? What value will be returned? int x=2,y=50; do { ++x; y = x ++; } while(x<=10); return y; (f) [2] What is the data type that the following library functions return? (i) isWhitespace(char ch) (ii) Math.random() [2] ut+ 1 ft2 2 [2] (g) Write a Java expression for (h) If int n[ ] ={1,2,3,5,7,9,13,16}, what are the values of x and y? x=Math.pow(n[4],n[2]); y=Math.sqrt(n[5]+n[7]); (i) [2] What is the final value of ctr when the iteration process given below, executes? int ctr=0; for(int i=1;i<=5;i++) for(int j=1;j<=5;j+ = 2) ++ctr; (j) [2] Name the methods of Scanner class that: (i) is used to input an integer data from the standard input stream (ii) is used to input a String data from the standard input stream. Examiners Comments (a) This question was answered correctly by most candidates. However, there were a few candidates who had interchanged the names of the class and the object given in the question. (b) A few candidates answered correctly. However a few lacked knowledge of string functions. 226 [2] Suggestions for teachers Creating an object of a class should be taught with examples. String function should be taught thoroughly. (c) (d) (e) (f) (g) (h) (i) (j) Most candidates wrote the correct answer. Some however misunderstood the question and wrote Suggestions for teachers the definition of encapsulation instead of writing Provide more practice in iterative the components that a class encapsulates. subroutines where candidates have Most candidates answered correctly. to predict the output especially Quite a few candidates were unable to analyze using looping statements. loop structure. Others did not seem to know the Emphasize on the output return type short hand operators and the difference between of all the mathematical functions post increment and pre increment operator. given in the syllabus. (i) Many candidates answered correctly . Additional practice should be given (ii) Most candidates could not write the correct in the writing arithmetic expressions answer. They wrote int as the answer instead in JAVA. of double. Teach how to substitute the values, This question was correctly answered by most if an address of array element is candidates. A few lost marks due to a missing given. asterisk or a wrong division symbol. Teach the working of nested loop This question was answered correctly only by a with or without curly brackets. few candidates as concepts of array with in a mathematical function was not understood by most candidates. Only a few candidates answered the question correctly. A number of candidates were unclear about the concept of nested loop when it is used without the curly brackets. Most candidates wrote the first part of the question correctly. However, in many cases the second part remained unanswered or incorrect answers were written. MARKING SCHEME Question - 3 (a) digital mp4=new digital(); digital mp4 = new digital() ; (b) str1= manners str2= good manners ( c) An class encapsulates data members that contain the information necessary to represent the class and member functions that performs operations on the data members. (d) if(sale>15000) comm= sale 5/100; else comm = 0; (e) Number of times loop executes: 5 Value returned: 15 (f) (i) boolean (ii)double 227 (g) (h) (i) (j) u t +1/2 Math.pow(t,2) x=343.0 or x=343 y=5.0 or x=5 ctr=15 (i) nextInt() (ii)next() OR nextLine() Question 4 Define a class named FruitJuice with the following description: Instance variables/data members: int product_code - stores the product code number String flavour - stores the flavour of the juice (E.g. orange, apple, etc.) String pack_type - stores the type of packaging (E.g. tetra-pack, PET bottle, etc.) int pack_size - stores package size (E.g. 200 ml, 400 ml, etc.) int product_price - stores the price of the product - Default constructor to initialize integer data members to 0 and Member methods: (i) FruitJuice() String data members to "". (ii) void input() - To input and store the product code, flavour, pack type, pack size and product price. (iii) void discount() - To reduce the product price by 10. (iv) void display() - To display the product code, flavour, pack type, pack size and product price. Examiners Comments Numerous types of errors were committed in this question, namely (i) Using a different class name than the one given in the question. (ii) A single function used instead of the ones asked for in the question. (iii) Transferring the formal parameter values to data members done incorrectly. (iv) Syntax of constructor was incorrect. (v) Calculations done using local variable instead of instance variables. MARKING SCHEME 228 [15] Suggestions for teachers Teach students constructors and functions. Students must write programs involving multiple functions. Explain the difference between instance variables and local variables. Instruct students to read the questions carefully before answering and they must use the class name, etc., as given in the question. Question - 4 import java.io.*;//import java.util.*; public class FruitJuice {intproduct_code, pack_size, product_price; String flavour, pack_type; BufferedReaderbr=new BufferedReader(new InputStreamReader(System.in)); //Scanner sc=new Scanner(System.in); publicFruitJuice() { product_code=pack_size=product_price=0; flavour=pack_type=""; } public void input()throws IOException//throwsInputMismatchException { System.out.println("Enter product code"); product_code=Integer.parseInt(br.readLine()); // sc.nextInt(); System.out.println("Enter flavour"); flavour=br.readLine(); // sc.next(); System.out.println("Enter pack type"); pack_type=br.readLine(); // sc.next(); System.out.println("Enter pack size in ml"); pack_size=Integer.parseInt(br.readLine()); // sc.nextInt(); System.out.println("Enter product price"); product_price=Integer.parseInt(br.readLine()); // 229 sc.nextInt(); } public void discount() { product_price =10; } public void display() { System.out.println("Product code="+product_code); System.out.println("Flavour="+flavour); System.out.println("Pack type="+pack_type); System.out.println("Pack size in ml="+pack_size); System.out.println("Product price = INR"+product_price); } public static void main()throws IOException { fruitJuice object = new fruitJuice(); object.input(); object.discount(); object.display(); } } Question 5 The International Standard Book Number (ISBN) is a unique numeric book identifier which is printed on every book. The ISBN is based upon a 10-digit code. The ISBN is legal if: 1 digit1 + 2 digit2 + 3 digit3 + 4 digit4 + 5 digit5 + 6 digit6 + 7 digit7 + 8 digit8 + 9 digit9 + 10 digit10 is divisible by 11. 230 Example: For an ISBN 1401601499 Sum=1 1 + 2 4 + 3 0 + 4 1 + 5 6 + 6 0 + 7 1 + 8 4 + 9 9 + 10 9 = 253 which is divisible by 11. Write a program to: (i) Input the ISBN code as a 10-digit integer. (ii) If the ISBN is not a 10-digit integer, output the message, "Illegal ISBN" and terminate the program. (iii) If the number is 10-digit, extract the digits of the number and compute the sum as explained above. If the sum is divisible by 11, output the message, "Legal ISBN". If the sum is not divisible by 11, output the message, "Illegal ISBN". [15] Examiners Comments: Suggestions for teachers Only a few candidates answered this question - Adequate practice should be given to correctly. Common errors observed were: students on programs using extraction (i) Ten digit code is accepted mostly as int or and counting of digits. double data type instead of long data type. - Students should be taught the technique (ii) Checking for 10 digit code is wrong. to convert a String data to a primitive (iii) Accepted the number as String and was not data type. converted into a number before doing the calculation. (iv) In case of calculating sum, candidates used loop incorrectly. (v) Loop used to multiply the extracted digits started from 1 to 10 instead of 10 to 1. for(i=1 ; i<=10;i++) { digit=n%10 s+=digit*i; n=n/10; } MARKING SCHEME Question - 5 public class ISBN { public void sampleMethod(long num) {longi,digit,sum=0; if(num>9999999999L || num<1000000000L) 231 System.out.println("Illegal ISBN"); else {for(i=10;i>=1;i--) {digit=num%10; sum+=digit*i; num=num/10; } if(sum%11==0) System.out.println("Legal ISBN"); else System.out.println("Illegal ISBN"); } } } Question 6 Write a program that encodes a word into Piglatin. To translate word into a Piglatin word, convert the word into uppercase and then place the first vowel of the original word as the start of the new word along with the remaining alphabets. The alphabets present before the vowel being shifted towards the end followed by AY . Sample input (1) : London, Sample output (1) : ONDONLAY Sample input (2) : Olympics, Sample output (2) : OLYMPICSAY Examiners comments: Many candidates committed the following errors (i) String literal which is input from the user was not converted to uppercase. (ii) Break Statement was missing. (iii) Loop taken up to the length() instead of length()-1. (iv) Mistakes in the syntax of string functions. (v) Printing was done inside the loop. 232 [15] Suggestions for teachers - All commonly used string functions should be taught with example programs. Regular practice should be given in programs using string manipulation. - Students should be taught how to extract words from a sentence. - Explain how the index of characters positioned in a string constant. MARKING SCHEME Question - 6 import java.io.*; class Piglatin { public static void main(String []args) throws IOException { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); // Scanner br=new Scanner(System.in); System.out.println("Enter a word"); String s=br.readLine();//br.next(); //paramterized input int x,y; String c,d; char b; s=s.toUpperCase(); x=s.length(); System.out.println(" The piglaitn word of the given string is "); for( y=0;y<x;y++) { b=s.charAt(y); if(b=='A'||b=='E'||b=='I'||b=='O'||b=='U') break; } c=s.substring(y,x); d=s.substring(0,y); System.out.println(c+d+"AY"); } } Question 7 Write a program to input 10 integer elements in an array and sort them in descending using the bubble sort technique. order [15] 233 Examiners Comments Common Mistakes made by most candidates were: (i) Selection sort technique was used instead of bubble sort technique. (ii) Ascending order in place of descending order. (iii) Syntax error in declaring or creating an array int a[] =new int a[10]; (iv) Array elements are assigned that are not accepted from the user. (v) Array elements are not displayed after sorting. Suggestions for teachers - Common errors should be highlighted to enable them to be rectified. - Advise students to read the question carefully. - Pupils must be told to avoid careless mistakes when declaring arrays. - Both bubble sort and selection sort techniques must be discussed and the difference between them must be explained clearly. MARKING SCHEME Question - 7 Qu import java.io.*; class bubble { public static void main(String args[])throws IOException { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); int a[]=new int[10]; System.out.println("Enter 10 elements"); for(int k=0;k<10;k++) { a[k]=Integer.parseInt(br.readLine()); } int temp; for( int i=0;i<9;i++) { for(int j=0;j<9-i;j++) { if(a[j]<a[j+1]) { temp=a[j]; 234 a[j]=a[j+1]; a[j+1]=temp; } } } System.out.println("Sorted elements are"); for(int k=0;k<10;k++) { System.out.println(a[k]); } } } Question 8 Design a class to overload a function series() as follows: (i) double series(double n) with one double argument and returns the sum of the series, sum = (ii) 1 1 1 1 + + +...+ 1 2 3 n double series(double a, double n) with two double arguments and returns the sum of the series, ............to n terms sum= 12 45 78 10 a a a a11 Examiners comments Common mistakes observed were: (i) Function overloading concept was not followed, two separate programs were written. (ii) Using void instead of double as return type. (iii) Candidates accepted the values from the user with in the function instead of accepting them as parameters. (iv) Declaration and Initialization of variable sum which is used to accumulate the value of the factions is not done properly. (v) Instead of repeating the loop n number of times the loop was repeated considering n as the final value to be checked for. 235 [15] Suggestions for teachers Function overloading concept should be taught to students clearly. Students need to be explained about when nested loop should be used. Advise students to read the question carefully and follow instructions. Teach students when double data type is used and how to initialize it with default values. Explain the importance of typecasting when finding the sum of real numbers is involved. MARKING SCHEME Question 8 public class overload { double sum, numerator,denominator,fraction; int i,j; public double series(double n) { sum=0.0; numerator=1.0; for(i=1;i<=n;i++) { denominator=(double)i; fraction=numerator/denominator; } sum+=fraction; returnsum; } public double series(double a, double n) { sum=0; denominator=1.0; for(i=1;i<=n;i=i+3) denominator=Math.pow(a,(i+1)); fraction=i/denominator; sum+=fraction; } return sum; }} Question 9 Using the switch statement, write a menu driven program: (i) To check and display whether a number input by the user is a composite number or not (A number is said to be a composite, if it has one or more than one factor excluding 1 and the number itself). Example : 4, 6, 8, 9 (ii) To find the smallest digit of an integer that is input. Sample input : 6524 Sample output : Smallest digit is 2 236 For an incorrect choice, an appropriate error message should be displayed. [15] Examiners comments: Suggestions for teachers A number of candidates misunderstood the question and wrote two separate programs without it being menu - Sufficient practice must be given on driven. A large number of candidates wrote the first part writing menu - driven programs. of the question correctly whereas for the second part of - Number problems like composite the question, they used complicated logic and thereby number and finding smallest digit of a made mistakes: Other commonly made errors were: given number should be taught to the students. (i) Break statement not used with switch case. (ii) Checking for number factors for composite program was done correctly. (iii) Zero (0) was assumed to be the smallest digit and compared with digits of the given number. MARKING SCHEME Question 9 import java.io.*; importjava.util.*; class overload { public static void main(String [] args) { Scanner obj=new Scanner (System.in); System.out.println("Enter a number"); intnum=obj.nextInt(); System.out.println("Menu"); System.out.println("1.COMPOSITE NUMBER OR NOT "); System.out.println("2.SMALLEST DIGIT"); System.out.println("Enter you choice "); int choice =obj.nextInt(); switch(choice) { case 1: int c=0; for(int i=2;i<=num/2;i++) 237 { if(num%i==0) c=c+1; } if(c>1) System.out.println(num+" is a composite number"); else System.out.println(num+" is not a composite number"); break; case 2: int smallest=9,digit; while(num!=0) { digit=num%10; if(digit<smallest) smallest=digit; num=num/10; } System.out.println( "smallest digit is "+smallest); break; default : System.out.println("Invalid choice"); } } } 238 Topics /Concepts found difficult Precedence of operators Wrapper class. Creating an object. Nested string functions. Analyzing the output of a do .while(); loop. Nested for( ) loop without braces. Return type of Math.random(). Scanner class. Suggestions for students Read the question carefully before answering. Do not forget to write the question number. Practice several programs on the computer. Answers and definitions should be short and precise according to the marks allotted. In programming, variable description is compulsory and should be mentioned with program. Do not memorize the program, try to understand the logic. Avoid terms/ words like SOP, SOPLN, PSVM, etc., for System.out.print. System.out.println, public static void main. In Section B, do not write the answer of any question twice, either repeating the same program or writing the program with a different logic. 239
|