X-CTA-Practice Paper – 2024 – 25
I. Name the Java feature depicted in the following pictures:-
1. 2.
3. 4.
5. 6.
8.
7.
9.
1
,II. Write Java expressions:-
x 3
3
√x+y 4 4 3
1. 2. √x 2 + y2 𝑥
3. 𝑎 + √𝑎2 + 𝑏2 4. 𝜋𝑟 5.(1 + )
|x−y| 3 y
III. Evaluate the given expressions and write the output:-
1. int m=7, n=9;
m+=m-- + ++n + ++m + --n;
System.out.println ("m="+m);
System.out.println ("n="+n);
2. int x=100, y=10;
x/=x-- + y++;
System.out.println ("x="+x+" y="+y);
3. int k= -6, j=2;
int r = ++k + ++j + --k;
System.out.println ("k="+k);
System.out.println ("j="+j);
System.out.println ("r="+r);
4. int s=1, t=5;
t*=--s + --t - ++s;
System.out.println ("s="+s);
System.out.println ("t="+t);
IV. Predict the output:
1. int a=5, b=3, c=7;
System.out.println (a+b*c/a);
System.out.println ((--a + b)==c);
System.out.println ("Output is "+a+b+c);
2. char c=67, x=50; int d=2;
System.out.println (c++);
System.out.println (c+d);
System.out.println ((char)(c+d));
System.out.println (x+=3);
System.out.println (x+d);
System.out.println ("Output is "+c+d);
3. int a=2, b=5;
if(b++%a++==0)
System.out.println (a+b);
if ((a+b)%3==0)
System.out.println (b-a);
else
System.out.println(a*b);
2
, 4. int k=50, j=5;
if(j%k==0)
if(j%5==0)
System.out.println (k/j);
else
System.out.println (k%j);
else
System.out.println (k+j);
5. When(a) ch is 'a' or 'A' (b) ch is 'd' or 'D'
switch (ch)
{
case 'a':
case 'A': System.out.println ("Accounts");
case 'c':
case 'C': System.out.println ("Commerce");
break;
default: System.out.println ("Incorrect Input");
}
6. double amount=5000, dis=0;
dis= (amount<=5000)? (amount*0.5):(amount*0.1);
System.out.println ("dis="+dis);
7. String s; int num=28;
s=(num%7==0)?(num%11==0)?"Divisible":"Divisible by 7, but not by 11":"Not divisible
by 7";
System.out.println (s);
8. Analyze how many times loop runs and what is the output:
int a=10;
while (++a<=20);
System.out.println (a);
9. Analyze how many times loop runs and what is the output:
String s="1a2b3c4d";
int i=0;
do
{
if (Character.isDigit(s.charAt(i)))
System.out.println ((s.charAt(i)-48)*2);
i++;
}while (i<s.length());
3
I. Name the Java feature depicted in the following pictures:-
1. 2.
3. 4.
5. 6.
8.
7.
9.
1
,II. Write Java expressions:-
x 3
3
√x+y 4 4 3
1. 2. √x 2 + y2 𝑥
3. 𝑎 + √𝑎2 + 𝑏2 4. 𝜋𝑟 5.(1 + )
|x−y| 3 y
III. Evaluate the given expressions and write the output:-
1. int m=7, n=9;
m+=m-- + ++n + ++m + --n;
System.out.println ("m="+m);
System.out.println ("n="+n);
2. int x=100, y=10;
x/=x-- + y++;
System.out.println ("x="+x+" y="+y);
3. int k= -6, j=2;
int r = ++k + ++j + --k;
System.out.println ("k="+k);
System.out.println ("j="+j);
System.out.println ("r="+r);
4. int s=1, t=5;
t*=--s + --t - ++s;
System.out.println ("s="+s);
System.out.println ("t="+t);
IV. Predict the output:
1. int a=5, b=3, c=7;
System.out.println (a+b*c/a);
System.out.println ((--a + b)==c);
System.out.println ("Output is "+a+b+c);
2. char c=67, x=50; int d=2;
System.out.println (c++);
System.out.println (c+d);
System.out.println ((char)(c+d));
System.out.println (x+=3);
System.out.println (x+d);
System.out.println ("Output is "+c+d);
3. int a=2, b=5;
if(b++%a++==0)
System.out.println (a+b);
if ((a+b)%3==0)
System.out.println (b-a);
else
System.out.println(a*b);
2
, 4. int k=50, j=5;
if(j%k==0)
if(j%5==0)
System.out.println (k/j);
else
System.out.println (k%j);
else
System.out.println (k+j);
5. When(a) ch is 'a' or 'A' (b) ch is 'd' or 'D'
switch (ch)
{
case 'a':
case 'A': System.out.println ("Accounts");
case 'c':
case 'C': System.out.println ("Commerce");
break;
default: System.out.println ("Incorrect Input");
}
6. double amount=5000, dis=0;
dis= (amount<=5000)? (amount*0.5):(amount*0.1);
System.out.println ("dis="+dis);
7. String s; int num=28;
s=(num%7==0)?(num%11==0)?"Divisible":"Divisible by 7, but not by 11":"Not divisible
by 7";
System.out.println (s);
8. Analyze how many times loop runs and what is the output:
int a=10;
while (++a<=20);
System.out.println (a);
9. Analyze how many times loop runs and what is the output:
String s="1a2b3c4d";
int i=0;
do
{
if (Character.isDigit(s.charAt(i)))
System.out.println ((s.charAt(i)-48)*2);
i++;
}while (i<s.length());
3