Solution To Computer Application 2022 Question Paper
Solution To Computer Application 2022 Question Paper
Question 1.
(i) b boolean
(ii) d toUpperCase(char)
(iii) b 5
(iv) c Float
(v) b Wrapper
(vi) a GoodDay
(vii) b N-1
(viii) a private
(ix) b 150.0
(x) c Luck
Question 2.
//Search an element using Binary Search Technique
import java.util.*;
class Question2
{
public static void main()
{
Scanner sc=new Scanner(System.in);
int a[]={2,5,7,10,15,20,29,30,46,50};
//Input the search element
System.out.println("Enter element to search :");
int n=sc.nextInt();
int l=0,u=a.length,mid;
while(l<=u)
{
mid=(l+u)/2;
if(a[mid]==n)
{
System.out.println("Element present at index number "+mid);
System.exit(0);
}
if(a[mid]<n)
l=mid+1;
if(a[mid]>n)
u=mid-1;
}
Question 3.
//Find the character with highest and lowest ASCII values
import java.util.*;
class Question3
{
public static void main()
{
Scanner sc=new Scanner(System.in);
char c[]=new char[10];
//Input
System.out.println("Enter 10 characters:");
for(int i=0;i<10;i++)
{
c[i]=sc.next().charAt(0);
}
int l=c.length,high=c[0],low=c[0];
for(int i=0;i<l;i++)
{
if(c[i]>high)
high=c[i];
if(c[i]<low)
low=c[i];
}
System.out.println("Character with highest ASCII value "+(char)high);
System.out.println("Character with lowest ASCII value "+(char)low);
}
}
Question 4.
//Find the square value of each element and product of all array elements
import java.util.*;
class Question4
{
public static void main()
{
Scanner sc=new Scanner(System.in);
double d[]=new double[10];
//Input
System.out.println("Enter 20 double type values:");
for(int i=0;i<10;i++)
{
d[i]=sc.nextDouble();
}
double pr=1.0;
int l=d.length;
for(int i=0;i<l;i++)
{
pr=pr*d[i];
System.out.println("Square of "+d[i]+"is " +(d[i]*d[i]));
}
Question 7.
//To check the first and last letters of the String
import java.util.*;
class Question7
{
public static void main()
{
Scanner sc=new Scanner(System.in);
//Input
if(l1!=l2)
{
System.out.println("Lengths are not same ");
System.exit(0);
}
for(int i=0;i<l1;i++)
{
ns=ns+s1.charAt(i)+s2.charAt(i);
}
System.out.println(ns);
}