Formatting page ...
UNISON WORLD SCHOOL, DEHRADUN 2nd Preliminary Examination (2019-2020) Computer Applications Theory: X Time:2 hrs Max Marks: 100 Instructions: Reading Time is 15 min. This paper is divided into two sections. Attempt all questions from Section A and any four questions from Section B The intended marks for questions or parts of questions are given in brackets []. SECTION A (40 Marks) (Attempt all questions) Q.1 (a) (b) (c) (d) (e) Q.2 (a) (b) (c) (d) Q.3 (a) (b) State the differences between: method and constructor class variable and instance variable next( ) and nextLine( ) indexOf( ) and lastIndexOf( ) Math.floor( ) and Math.ceil( ) [2] [2] [2] [2] [2] State the method that: (i) Converts a string to a primitive double data type. (ii) Determines if the specified character (x) is an Upper case character. (iii) Find and display the position of the last space in a string s. (iv) Convert the second character of a string str in upper case. What is exception? Name 2 ways to handle exception. What is base class and derived class? Name the keyword used (i) to inherit a class and (ii) include a package in a class. [4] What will be the output of the following program segments? i) String s = "2.37058"; int n=s.indexOf( . ); int c = Integer.parseInt(s.substring(0, n)); int t = Integer.valueOf(s.substring(n+1)); System.out.println(c); System.out.println(t); ii) String s= Examination ; int a= s.length(); System.out.println(s.startsWith(s.substring(5, a))); System.out.println(s.charAt(2)==s.charAt(6)); iii) int a=20, b=15; if(a>10) {a++; b--; } System.out.println(a+ , +b); What will be the output of the following code? int a=1, b=2, c=3; switch(p) { case 1:a++; case 2: ++b; break; [2] [2] [2] [2] [2] [2] [3] (c) Q.4 (a) (b) (c) (d ) case 3: c--; } System.out.println(a + , + b + , +c); when (i) p=1 and (ii) p=3 Write the Java expression for the following: (0.25 2 y3)/(x-y). State the differences between bubble sort and selection sort. If int x[ ] = {0, 4, 6, 8}, what is the value of m ? x[0] = 20; x[3] = x[1]; int m= x[0] + x[1] System.out.println( Sum= +m); What will be the output of the following? int arr[][]={{9,5,0},{0,4,-1},{5,2,8}}; arr[1][1]= 6; arr[0][1]= -9; System.out.print(arr[0][1]+arr[1][2]*arr[1][1]); Evaluate the expression if values of the variables are a=2, b=3, c=9; a (b++) * (--c) [1] [2] [2] [4] [2] SECTION B (60 Marks) (Attempt any four questions from this section) Q.5 Define a class called Account that calculates the telephone bill of a consumer with the following description: Instance variables/data members: String name stores the name int n stores the bill number int call no. of calls consumed in a month double amt bill amount to be paid Member Methods: Account() parameterised constructor to initialize data members by accepting details of a student. void calculate() to calculate the monthly telephone bill for a consumer as per the following condition: Units consumed First 100 calls Next 100 calls Next 100 calls Above 300 calls [15] Rate Rs. 0.60/ call Rs. 0.80/ call Rs. 1.20/ call Rs. 1.50/call void display(): To display the details Write the main method to create an object of a class and call all the above member methods. Q.6 Design a class to overload a function Series() with following specifications: (i) void Series(int n): to display the given series upto n terms. Example: if n is 5, then output is 0,3,8,15,24 (ii) void Series(): calculates and returns the sum of the given series: Sum= 1 2 3 4 5 7 6 8 + + 9 10 Write main method and invoke above methods by creating objects [15] Q.7 Write a menu driven program to display the following patterns: i) 1 ii) Z Y X W V 21 ZYXW 321 ZYX 4321 ZY 54321 Z [15] Q.8 Write a program in Java to input a sentence and display only those words which begin with a vowel. Sample Input : IT ALWAYS SEEMS IMPOSSIBLE UNTIL IT S DONE Sample output : Words started with vowels are: IT, ALWAYS, IMPOSSIBLE, UNTIL, IT S [15] Q.9 Write a program to input name and percentage of 35 students of class X in two separate one dimensional arrays. Arrange students details according to their percentage in the descending order using selection sort method. Display name and percentage of first ten toppers of the class. [15] Q.10 Write a program to create a Double Dimensional Array (DDA) to store the first 9 natural numbers row-wise and find the sum of left diagonal and right diagonal elements. int num[ ] [ ] =new int[3][3]; Sample Input: 1 2 3 4 5 6 7 8 9 Sample output: Sum of left diagonal elements:15 and Sum of right diagonal elements:15 [15]
|