Formatting page ...
PAWAR PUBLIC SCHOOL, CHANDIVALI FIRST PRELIMINARY EXAMINATION (2022 2023) SUBJECT: COMPUTER APPLICATIONS GRADE: 10 MARKS: 100 DATE: 16.11.2022 TIME: 2 HOURS Answers to this Paper must be written on the paper provided separately. You will not be allowed to write during the first 15 minutes. This time is to be spent in reading the question paper. The time given at the head of this Paper is the time allowed for writing the answers. This Paper is divided into two sections. Attempt all questions from Section A and any four questions from Section B The intended marks for question or parts of questions are given in brackets []. This Paper consists of 6 printed sides -------------------------------------------------------------------------------------------------------Section A (Attempt all question from this Section) Question 1 Choose the correct answer and write the correct option. [20] (i) Which of the following keywords is used to create an instance of a class? (a) public (b) static (c) void (d) new (ii) Which of the following keyword is used as an access specifier? (a) new (b) public (c) class (d) void (iii) In case you need to give a proper message (prompt string) before taking an input from the user, which would be the most preferable method? (a) Parameterised input (b) Initialisation (c) Scanner input (d) Declaration (iv) Which one of the following methods will return a value between 0 and 1? (a) Math.pow() (b) Math.abs() (c) Math.min() (d) Math.random() (v) Which one of the following types of error will give the following code? for(int i = 1; i>10; i++) (a) Syntax (b) Runtime (c) Logical (d) System (vi) Which of the following is an example of prefix decrement operator? (a) i + + (b) a - (c) - - a (d) + + a What is the name given to a memory location called in Java? (a) Variable (b) Constant (c) Data Type (d) Constructors In logical operators, which operator has the highest precedence? (a) && (b) || (c) >> (d) ! If int n[ ] = {1, 2, 3, 5, 7, 9, 13, 16}; what will be the value of x ? x = Math.pow(n[4], n[2]); (a) 343.0 (b) 25.0 (c) 343 (d) 8.0 (vii) (viii) (ix) 2 PPSC/22-23/IIT/10/CTA/FPE 2 (x) If break is not used with switch case, then the program___________. (a) causes a syntax error (b) executes normally (c) causes fall through situation (d) causes a logical error (xi) How many times the loop will execute? int i = 1; while (i < 4) { System.out.println((i+2) + ); i = i + 2; } (a) Zero times (b) Two times (c) Three times (d) One time (xii) __________ loop checks the condition first before its execution. (a) While (b) Switch (c) Do While (d) If Else If (xiii) If int x[ ] = {4, 3, 7, 8, 9, 10}; what is the length of x? (a) 4 (b) 5 (c) 6 (d) 10 Which OOP principle implements function overloading? (a) Inheritance (b) Polymorphism (c) Encapsulation (d) Data Abstraction (xiv) (xv) Give the output of the following statements: String x[ ] = { SAMSUMG , NOKIA , SONY , MICROMAX , BLACKBERRY }; System.out.println(x[1]); (a) Samsung (b) Nokia (c) Sony (d) No output (xvi) Which of the following is a primitive data type? (a) Double (b) Integer (c) float (d) Boolean (xvii) Which of the following is a block of statements in a program that performs a specific task? (a) Class (b) Object (c) Method (d) Data type (xviii) Which of the following operators is used to concatenate two or more strings? (a) * (b) ^ (c) + (d) # (xix) Variable that is declared with in the body of a method is termed as_______. (a) Instance variabl (b) class variable (c) Local variable (d) Argument variable (xx) The access modifier that gives most accessibility is_______. (a) private (b) public (c) protected (d) package 3 PPSC/22-23/IIT/10/CTA/FPE 3 Question 2 (i) Evaluate the following expression. a+ = a++ + ++a + - - a + a - -; when a = 7 |. [2] (ii) Write Java Expression for | (iii) Rewrite the following into ternary operator. if (sale >15000) comm = sale * 5/100; else comm = 0; [2] (iv) Rewrite the following while loop using For loop. int m = 5, n = 10; while (n>=1) { System.out.println(m * n); n--; } [2] (v) How many times will the following loop execute? What value will be returned?[2] int x = 2, y = 50; do { ++x; y - = x++; } While (x <=10); return y; (vi) What will be the output of the following statement? [4] a) Computer Applications . Replace ( o , a ); b) REDUCE .compareTo( REVOLT ) + ANTARTICA .lastIndexOf( A ); (vii) Write any two points of difference between Implicit Type Conversion and Explicit Type Conversion. [2] [2] 4 PPSC/22-23/IIT/10/CTA/FPE 4 (viii) Consider the following program and answer the questions given below. class myClass { Static int x=7; int y=2; public static void main(String args[]) { myClass obj = new myClass(); System.out.println(x); obj.sampleMethod(5); int a = 6; System.out.println(a); } void sampleMethod(int n) { System.out.println(n); System.out.println(y); } } a) State the name and value of class variable. b) State the name and value of local variable. [2] (ix) [2] Consider the following array and answer the questions given below. char m[ ] = { R . A , J , E , N , D , R , A }; a) What is the size of the array? b) What is the position of E ? Section B (60 Marks) Attempt any four questions from this Section. The answers to this Section should consist of the Programs in either Blue J environment or any program environment with Java as the base. Each program should be written using Variable descriptions/ Mnemonic Codes so that the logic of the program is clearly depicted. Flow-Charts and Algorithms are not required. Question 3 Define a class called Library with the following description. Instance variables /data members: int acc_num : stores the accession number of books String title: stores the title of book String author: stores the name of author [15] 5 PPSC/22-23/IIT/10/CTA/FPE 5 Member methods: void input() : to input and store the accession number, title and author void compute() : to accept the number of days late, calculate and display the fine charged the rate of 2 per day void display() : to display the details in the following format Accession number Title Author .. . Write the main method to create an object of the class and call the above member methods. Question 4 [15] Design a class to overload a function check() as follows: void check(String str, char ch) to find and print the frequency of a character in a string. Example: Input: str = success ch = s Output: Number of s present is = 3. void check (String s1) to display only vowels from s1, after converting it to lowercase. Example: Input: s1 = computer Output: o u e 6 PPSC/22-23/IIT/10/CTA/FPE 5 Member methods: void input() : to input and store the accession number, title and author void compute() : to accept the number of days late, calculate and display the fine charged the rate of 2 per day void display() : to display the details in the following format Accession number Title Author .. . Write the main method to create an object of the class and call the above member methods. Question 4 [15] Design a class to overload a function check() as follows: void check(String str, char ch) to find and print the frequency of a character in a string. Example: Input: str = success ch = s Output: Number of s present is = 3. void check (String s1) to display only vowels from s1, after converting it to lowercase. Example: Input: s1 = computer Output: o u e 6 PPSC/22-23/IIT/10/CTA/FPE 6 Question 5 [15] Write a program in Java to store 20 temperatures in F in a Single Dimensional Array (SDA) and display all the temperatures after converting them into C. Hint: (c /5) = (f - 32) / 9 Question 6 [15] Write a program to generate a triangle or an inverted triangle based on User s choice. Example 1: Example 2: Input: Type 1 for a triangle and Input: Type 1 for a triangle and Type 2 for an inverted triangle Type 2 for an inverted triangle Enter your choice 1 Enter your choice 2 Sample Input : 12345 Sample Input : 12345 Sample Output: Sample Output: 1 54321 12 4321 123 321 1234 21 12345 1 QUESTION 7 [15] Write a program to input 10 numbers into an integer array and find the position of the largest and the smallest number. *** PPSC/22-23/IIT/10/CTA/FPE 6 Question 5 [15] Write a program in Java to store 20 temperatures in F in a Single Dimensional Array (SDA) and display all the temperatures after converting them into C. Hint: (c/5) = (f - 32) / 9 Question 6 [15] Write a program to generate a triangle or an inverted triangle based upon User s choice. Example 1: Example 2: Input: Type 1 for a triangle and Input: Type 1 for a triangle and Type 2 for an inverted triangle Type 2 for an inverted triangle Enter your choice 1 Enter your choice 2 Sample Input : 12345 Sample Input : 12345 Sample Output: Sample Output: 1 54321 12 4321 123 321 1234 21 12345 1 QUESTION 7 [15] Write a program to input 10 numbers into an integer array and find the position of the largest and the smallest number. ***
|