861-22-3
861-22-3
861-22-3
SAMPLE PAPER - 3
COMPUTER APPLICATIONS
Maximum Marks: 50
Time allowed: One and a half hours
Answers to this Paper must be written on the paper provided separately.
You will not be allowed to write during the first 10 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.
Attempt all questions from Section A and any four questions from Section B.
SECTION A
(Attempt all questions.)
Answers
Section-A
Answer 1.
(i) (b) Abstraction
Explanation :
Data abstraction can be achieved by using encapsulation. We can hide the operation and structure of
actual program from the user and can show only required information by the user.
(ii) (b) false
Explanation :
As strings x and y are not equal so x.equals(y) returns false.
(iii) (c) 15
Explanation :
The length() function returns the number of characters in a String.
(iv) (a) Understanding Computer Applications10
Explanation :
In the first line, + operator concatenates 1 and 0 to the end of “Computer Applications” so str becomes
“Computer Applications10”.
“UnderstandingComputer Applications10” to the console.
(v) false
Explanation :
Both “BLUEJ” and “bluej” have the same length 5. So, condition of ternary operator is false and false is
assigned to boolean variable p.
(vi) (a) false
JAI
Explanation :
As length of the string “DELHI” is less than that of “LUCKNOW” so first output is false. arr[4].
substring(0,3) will return the substring of “JAIPUR” starting at index 0 till index 2 (i.e. 3 - 1 = 2).
(vii) The result is true
Explanation :
str1.equalsIgnoreCase(str2) will do a case insensitive comparison of str1 and str2. As both strings contain
the same characters if we ignore the case so it returns true which is stored in boolean variable p.
(viii) (b) public
Explanation :
main() method must be specified public as it called by Java run time system, outside of the program.
If no access specifier is used then by default member is public within its own package and cannot be
accessed by Java run time system.
(ix) (a) private
Explanation :
When we pass an argument by call-by-value a copy of argument is made into the formal parameter of
the subroutine and changes made on parameters of subroutine have no effect on original argument,
they remain the same.
(x) (c) true, false
Explanation :
s1.equalsIgnoreCase(s2) compares the two strings without considering the case, hence returns true.
s1.equals(s2) compares the two strings considering the case, hence returns false. So output is true,
false :
Section-B
Answer 2.
import java.util. Scanner;
public class Vowelwords
{
public static void main(String[] args)
{
String sen=””,word=””; int i;
char ch;
Scanner sc=new Scanner(System.in); sen=sc.nextLine();
for(i=0;i< sen.length();i++)
{
if (sen. charAt(i)!=’ ‘)
{
word+=sen.charAt(i);
}
else
{
ch=word. charAt(0);
if (ch==’a’ || ch==’e’ || ch==’i’ || ch==’o’ || ch==’u’)
System.out.println(word);
word=””;
}
}
}
}
Answer 3.
import java.util.Scanner;
public class NumberOccurance
{
public static void main(String args[])
{
Scanner in = new Scanner(System.in);
System.out.print(“Enter a number: “);
{
Scanner in = new Scanner(System.in);
System.out.println(“Enter a word or sentence:”); String str = in.nextLine();
if (word.length() >
lWord.length()) lWord =
word;
word = “”;
}
else
{
word += ch;
}
}
System.out.println(“The longest word: “ + lWord + “: The length of the word: “ + lWord.
length());
}
}
Answer 6.
import java.util.Scanner;
public class CompositeNumbers
{
public static void main(String args[])
{
Scanner in = new
Scanner(System.in);
int arr[] = new int[20];
System.out.println(“Enter 20 numbers”); for (int i = 0; i < arr.length; i++)
{
arr[i] = in.nextInt();
}
int c = 0;