0% found this document useful (0 votes)
39 views

CL 10 - COMP APP - QUESTION PAPER-Answer key

Uploaded by

0613.apobangpo.7
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views

CL 10 - COMP APP - QUESTION PAPER-Answer key

Uploaded by

0613.apobangpo.7
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

THE BISHOP’S CO-ED SCHOOL, UNDRI

FIRST TERMINAL EXAMINATION – 2022-2023


COMPUTER APPLICATIONS
(2 Hours)
Class – X Max.Marks – 100

Answers to this Paper must be written on the paper provided by the school.
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 Aand any 4 questions from Section B.
The intended marks for questions or parts of questions are given in brackets.
SECTION A (10 Marks)
Attempt all questions
Question 1. [20]

Choose the correct answer and write the correct option.

(i) The method to check if a character is an alphabet or not is:


(a) isLetter(char) (b) isAlpha(char)

(c) isUppercase(char) (d) isLowercase(char)

(ii) Predict the output of the following


Math.pow (3,2) + Math.ceil (4.2)
(a) 15.0
(b) 14.0
(c) 13.0
(d) 12.0

(iii) Which of the following declaration and initialization is the below line equivalent to?
String str = new String( ) ;
(a) String str = “”;
(b) String str = “0”;
(c) String str = null;
(d) String str = “\0”;

(iv) The element is x[4] of the array {3, 5, 7, 12, 16, 18, 20, 35, 42, 89} is:
(a) 16 (b) 12 (c) 7 (d) 18

(v) You can execute ----------------- methods even when no objects of a class exist,
whereas -------------- methods can be executed only in relation to a particular object,
so if no objects exist, you have no way to execute any of the instance methods
defined in the class.
(a) class , instance (b) Instance , class

(c) Instance , instance (d) None of these

(vi) What will be the output of the below mentioned code


int val=2;
switch(val)

Page 1 of 4
{
case 1:System.out.println(“Case 1”);
break;

case 2:System.out.println(“Case 2”);


break;
default :System.out.println(“No match found”);
break;
}
(a) Case 1 (b) Case 2 (c) error in the code (d) No match found

vii)Find the output of the following

if int x=5

x += x++ + ++ x + --x + x;

(a) 29 (b) 28 (c) 26 (d) 25

viii)Write the output of the following:

String s="Today is Test";


System.out.println(s.substring(0,7)+""+"Holiday");

(a) Today is Holiday (b) Today is Holiday

(c) Today i Holiday (d) Today iHoliday

ix)Automatic conversion of primitive data into an object of wrapper class is called:

(a) Autoboxing (b) Explicit conversation

(c) Shifting (d) None of these

x) Java uses the 16 bits ______ character set to represent the character data.

(a) literal (b)Bytecode (c)Unicode (d)binary

(xi)What is printed out from the below code?

String str = “Abhiram Kripal Singh”;


System.out.println ( str. indexOf (‘S’) ) ;

(a) 14 (b) 15 (c) 16 (d) 17

(xii) Give the output of the following:

Math.abs(Math.floor(-5.9));

(a) -5.0 (b) 9.0 (c) -6.0 d)6.0

xiii) Name the package that contains wrapper classes

(a) java.util (b) java.lang (c) java.io (c) java.wrapper

Page 2 of 4
(xiv) Rather than the use of Character.isLowerCase(ch), what other test can you use to
check whether the character is lowercase or not?0

(a) if( ch >=’a’ && ch<=`z’ ) (b) if( ch >=’A’ && ch<=`Z’ )

(c) if( ch.LOWER ==true) (d) None of these

(xv) (xv) For every object, separate memory is allocated to its __________ variables.

(a) Instance (b) Dynamic (c) Parameter (d) Static

(xvi) What is the difference between the compareTo() and equals() method?

(a) Return type of compareTo() returns an integer and equals() returns boolean
(b) Knowledge of the string compareTo() method returns the lexicographic status
while equals() returns only whether the strings are equal or not
(c) Both (a) and (b)
(d) They are the same functions, with name changed

(xvii) The statement to invoke the default constructor of a class “State” is _________

(a) State obj= new state ; (b) State obj = State() ;

(c) State obj= new State() ; (d) State obj= new State(int a)

(xviii) What is the output of the following code?

char c=’B’;

int i=4;

System.out.print(c+i);

System.out.print((int)c+i);

(a)7070 (b) 6868

(c) 9898 (d)102102

(xix) Which keyword causes an immediate exit from the switch case or loop?

(a) break (b) continue (c) jump (d) exit

(xx) Within a string x, and the character ch, what is the way to call the indexOf() method?

(a) x.indexOf(ch) (b) x.indexOf(x,ch) (c) indexOf(ch,x) (d) indexOf(x,ch)

Question 2. [20]

(i) Rewrite the following code using a while loop.


String s = “Dev Kumar”;
for(int i = 0;s.charAt (i) != ` `; i++)
{
System.out.println (s.charAt (i)) ;
}

Page 3 of 4
Ans. String s = “ Dev Kumar”;

int i = 0;

while(s.charAt(i) != ` `)

System.out.print (s.charAt (i));

i++;

(ii) What is the difference between static and non-static methods in a class?
Static methods have the static keyword
No object is required to invoke a static method
Non-static methods have no static keyword
An object is necessary to invoke the non-static methods
(iii) What is the output of the following code:

"abracad".endsWith("abc")&& "optim".startsWith("opi")

Ans. False

(iv) What will be the output of the following code?


int k = 5,j=9;
k+=k++ - ++j + k;
System.out.println("k ="+k);
System.out.println("j="+j);
Ans: k =6
j=10

(v) double b = -15.6;


double a = Math.round(Math.abs(b));
System.out.println(“a=”+a);

Ans: a=16.0

(vi) Find the errors in the given program segment and re-write the statements correctly
to assign values to an integer array.
int a = new int (5);
for(int i =0; i <=5; i + +)
a[i] = i;
Ans: int a[]=new int[5];
for(int i=0;i<5;i++)
a[i]=i;
(vii) What will be the output of the following:
int val, sum, n=550;
when
i) val=500
ii) val=1600
sum=n+val>1750?400:200;
System.out.println(sum);
Ans:i)200

Page 4 of 4
ii)400
(viii) How many times the loop will be executed.
for(int x=1;x<=10;x++)
{
System.out.println(x);
if(x==5)
break;
}
Ans: 5 times

(ix) What are Relational operators? Explain the different types of Relational operators?
Relational operators are used to compare the relationship between two data-items
in a conditional expression. For eg. >, <, >=, <=, ==, !=
(x) What will be the output of the following
class First{
public static void main(String args[])
{
int a[]={5,1,15,20,25};
int i,j;
int m;
i=++a[1];
j=a[2]++;
m=a[i++];
System.out.print(i+” ”+j+” “+m);
}
}
Ans: 3 15 16

SECTION B(60 Marks)


Attempt any four questions from this Section.
The answers in 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 : [15]

Write a program to bubble sort the following set of values in ascending order.

5,3,8,4,9,2,1,12,98,16.

//To sort the given array in ascending order

public class BubbleSort

public static void main()

int i,j,temp=0;

int a[]={5,3,8,4,9,2,1,12,98,16};

Page 5 of 4
for(i=0; i<=9; i++)

for(j=0; j<(9-i); j++)

if(a[j]>a[j+1])

temp=a[j];

a[j]=a[j+1];

a[j+1]=temp;

} }}

System.out.println("Array elements after sorting");

for(i=0; i<=9; i++)

System.out.print(a[i]+" ");

Question 4 : [15]

The following program is based on the specifications given below. Write a program in java
such that:

class name : telephone

member variables: int noc [number of calls]

double bill[telephone bill to be paid]

String n[name of the customer]

member methods:

void input() - to accept the data using the Scanner class

void print() – to print the details i.e. name of the customer, no of calls and the bill amount

void calculate() – to calculate the telephone bill as per the following criteria based on the
number of calls

rate per call

First 100 calls free

Above 100 calls Rs 2.50 per call.

void main() – to create an object of the class and invoke the functions of the class

Page 6 of 4
/*Program to calculate the telephone bill of the customer */

import java.util.*;

public class Telephone

int noc;

double bill;

String n;

public void input()

Scanner sc=new Scanner(System.in);

System.out.println("Enter the name of the customer and the number of calls made by the
customer");

n=sc.nextLine();

noc=sc.nextInt();

public void calculate()

if(noc<=100)

bill=0.0;

else

bill=2.5*(noc-100);

public void print()

System.out.println("Data of the customer");

System.out.println("Name"+n);

System.out.println("No of calls"+noc);

System.out.println("bill "+bill);

public static void main()

Telephone obj=new Telephone();

Page 7 of 4
obj.input();

obj.calculate();

obj.print();

/*Program to calculate the telephone bill of the customer */

import java.util.*;

public class Telephone

int noc;

double bill;

String n;

public void input()

Scanner sc=new Scanner(System.in);

System.out.println("Enter the name of the customer and the number of calls made by the
customer");

n=sc.nextLine();

noc=sc.nextInt();

public void calculate()

if(noc<=100)

bill=0.0;

else

bill=2.5*(noc-100);

public void print()

System.out.println("Data of the customer");

Page 8 of 4
System.out.println("Name"+n);

System.out.println("No of calls"+noc);

System.out.println("bill "+bill);

public static void main()

Telephone obj=new Telephone();

obj.input();

obj.calculate();

obj.print();

Question 5 : [15]

Define a class to accept the names of 10 students in an array and print the words which begin
with “AM” and count the number of words beginning with “AM”.

/*Program to count the words beginning with "AM" */


import java.util.*;
public class Am
{
public static void main()
{
Scanner sc = new Scanner(System.in);
String n[] = new String[10];
int c=0;
System.out.println("Enter names of students ");
for(int i=0; i<=9; i++)
{

n[i]=sc.next();
}
for(int i=0; i<=9; i++)
{
n[i]=n[i].toUpperCase();
if (n[i].startsWith("AM"))

c++;

}
System.out.println(c);
}
}//class ends

Question 6 : [15]

Write a program in Java to enter a sentence. Display the words which are only
palindrome.
Sample input: MOM AND DAD ARE NOT AT HOME

Page 9 of 4
Sample output: MOM
DAD

//To count the palindrom words


import java.util.*;
public class Palindrome
{
public static String reverse(String m)
{
String word=m;
String rev="";

for (int j =0; j <m.length(); j++)

rev=m.charAt(j)+rev;

return rev;

}
public static void main()
{
int c=0,i=0,j;
Scanner sc = new Scanner(System.in);
System.out.println("Enter a sentence:");
String str = sc.nextLine();
str=str+" ";
String word="",revWord="";
while(i<str.length())
{
int p = str.indexOf(' ',i);
word=str.substring(i,p);
if(word.length()!=0)
{
revWord=reverse(word);
if(word.equalsIgnoreCase(revWord))
c++;
}
i=p+1;

}
System.out.println(c);
}

Question 8 : [15]

Design a class to overload a function series() as follows:

Page 10 of 4
i) double series(double n) with one double argument and returns the sum of the
series. Sum=1/1 +1/2 +1/3 +…..1/n
ii) double series(double a, double n) with two double arguments and returns the sum
of the series.
sum = 1/a2+4/ a5+7/ a8+10/ a11….. to n terms

public class Series1


{
double series(double n)
{
double sum=0;
for(double i=1; i<=n; i++)
sum +=1/i;
return sum;
}
double series(double a, double n)
{
double sum =0.0;
int terms = (int)Math.round((n));
double nr = 1.0, dr = 2.0;
for(int i=1; i<= terms; i++)
{
double term = nr/(a*dr);
sum += term;
nr += 3.0;
dr += 3.0;
}
return sum;
}

*********************

Page 11 of 4

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy