ICSE 2017 Computer Applications Class X Question Paper (Solved) JAVAPBA
ICSE 2017 Computer Applications Class X Question Paper (Solved) JAVAPBA
HEALTH
ALL-9239412412/8620825343
Question 2:
a) Name of the following : [2]
i) A keyword used to call a package in the program.
ii) Any one reference data types.
Ans. i)import ii) array
c) State the data type and value of res after the following is executed :
[2]
char ch=‘t’;
res=Character.toUpperCase(ch);
Ans. Date type of res = char and value of res = T
Question 3:
a) Write a Java expression for the following : [2]
Ans.
import java.util.*;
class Question6
{
public static void main(String args[])
{
Scanner sc= new Scanner(System.in);
int n;
double s=0;
System.out.println("1.S= x1-x2+x3-x4....");
System.out.println("2.1 11 111 1111 11111");
System.out.println("Enter your choice");
n=sc.nextInt();
switch(n)
{
case 1:
int x=2,y=2;
for(int i=1;i<=20;i++)
{
if(y%2==0)
s=s + Math.pow(x,i);
else
s=s - Math.pow(x,i);
y++;
}
System.out.println("S="+s);
break;
case 2:
int d=1,s1=0;
for(int i=1;i<=5;i++)
{
s1=s1*10+d;
System.out.print(s1+"\t");
}
break;
default:
System.out.println("Invalid Input");
}
}
}
Question7. [15]
Write a program to input integer elements into an array of size 20
and perform the following operations :
i) Display largest number from the array
ii) Display smallest number from the array
iii) Display sum of all the elements of the array
Ans.
import java.util.*;
class Quesion7
{
public static void main(String args[])
{
int a[]=new int[20];
Scanner sc = new Scanner(System.in);
int max,min,s=0;
System.out.println("Enter the 20 numbers");
for(int i=0;i<19;i++)
{
a[i]=sc.nextInt();
}
max=a[0];min=a[0];
for(int i=0;i<19;i++)
{
s=s+a[i];
if(a[i]>max)
max=a[i];
if(a[i]<min)
min=a[i];
}
System.out.println("Largest no="+max);
System.out.println("Smallest no="+min);
System.out.println("Sum of all elements="+s);
}}
Question 8:
Design a class to overload a function check() as follows:
i) void check(String str, char ch) – to find and print the frequency of a
character
in a string.
Example :
Input Output
Str= “success” number of s present is=3
ch= ‘s’
ii) void check (String s1) – to display only the vowels from string s1 ,
after converting it to lower case.
Example :
Input:
S1= “computer” output: o u e
Ans.
import java.util.*;
class Question8
{
void check(String str,char ch)
{
int c=0;
for(int j=0; j<str.length(); j++)
{
char ch2=str.charAt(j);
if(ch==ch2)
c++;
}
if(c!=0)
{
System.out.println("Number of "+ch+" present is "+c);
}
}
void check(String s1)
{
String s=s1.toLowerCase();
System.out.println("Vowels are");
for(int i=0;i<s.length();i++)
{
char ch=s.charAt(i);
if(ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')
System.out.print(ch+" ");
}
}
public static void main(String args[])
{
Scanner sc= new Scanner(System.in);
String str,s2;char ch;
System.out.print("Enter any string: ");
str=sc.nextLine();
System.out.print("Enter any char: ");
ch=sc.next().charAt(0);
Question8 ob = new Question8();
ob.check(str,ch);
ob.check(str);
}
}
Output:
Enter any string: success
Enter any char: s
Number of s present is 3
Vowels are
ue
Enter any string: COMPUTER
Enter any char: M
Number of M present is 1
Vowels are
o u e
Question 9:
Write a program to input forty words in an array. Arrange these
words in descending order of alphabets, using selection sort
technique. Print the sorted array.
Ans.
import java.util.*;
public class Question9
{
public static void main(String[] args)
{
String temp;
Scanner s = new Scanner(System.in);
String names[] = new String[40];
Scanner sc = new Scanner(System.in);
System.out.println("Enter all the names:");
for(int i = 0; i < 5; i++)
{
names[i] = sc.nextLine();
}
for (int i = 0; i < 5; i++)
{
for (int j = i + 1; j < 5; j++)
{
if (names[i].compareTo(names[j])<0)
{
temp = names[i];
names[i] = names[j];
names[j] = temp;
}
}
}
System.out.print("Names in Sorted Order:");
for (int i = 0; i <5; i++)
{
System.out.print(names[i] + ",");
}
}
}
Share This: Facebook Twitter Google+ Stumble Digg
Related Posts: