0% found this document useful (0 votes)
7 views3 pages

Practice Paper

The document consists of various Java programming revision questions covering keywords, data types, methods, output predictions, loop analysis, function prototypes, and Java statements. It includes tasks such as identifying specific keywords, classifying data types, writing outputs for given statements, and rewriting code using the ternary operator. Additionally, it asks for Java statements to perform specific actions like accepting input and importing packages.

Uploaded by

farahsfbn
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)
7 views3 pages

Practice Paper

The document consists of various Java programming revision questions covering keywords, data types, methods, output predictions, loop analysis, function prototypes, and Java statements. It includes tasks such as identifying specific keywords, classifying data types, writing outputs for given statements, and rewriting code using the ternary operator. Additionally, it asks for Java statements to perform specific actions like accepting input and importing packages.

Uploaded by

farahsfbn
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/ 3

Revision Questions

I. Name the specific keyword in java


1. To allocate memory space for a composite datatype
2. To exit from the switch block.
3. Indicates the function does not return any value.
4. To store the values true/false.
5. To force early iteration in a loop.
6. To utilize the classes in a program present in other packages.
7. To store decimal values Upto the precision of 7 digits.
8. To group similar classes together.
9. To refer to the current instance of the class.

II. Classify the following as Primitive/Composite data types


1. String s1=new String (“Welcome”);
2. float f[]=new float[100];
3. int x=Integer.parseInt (sc.nextLine());
4. String s=sc.nextLine ();
5. double d=sc.nextDouble ();
III. Name the method/function in java
1. To convert numerical string to a number.
2. To parse tokens as float values from the Scanner object.
3. To remove the space before and after the string.
4. To find the largest of two numbers

IV. Write the output of the following statements


1. System.out.println(“Output is “+’A’+’P’);
2. System.out.println(‘V’+5+” is the Output”);
3. System.out.println(“My age is “+1+5);
4. System.out.println(“The Result is “+5*4+2%4);
5. System.out.println (“\”Health is Wealth\””);
6. double d=456.78932; int x=45; int y=x+(int)d; System.out.println (y);
7. int a=-7, b=-4, c=-10; a*=++a/c++ + b++*++a + c; System.out.println(a);
8. char ch1=’A’, ch2=’a’, ch3=(char)(ch2-32+5); System.out.println(ch1++ +
“ “+ch3);
9. int x=10; System.out.println(x=20); ++x; x++; System.out.println(x);
10. int x=5, y=10; System.out.println(x/y+” “+(double)x/y);

V. Write the Output:


1. int p=500;
if(p<=100);
System.out.println (p++);
System.out.println (++p);

2. int op=5;
switch(op++)
{
case 5: System.out.println(op+2);
case 10: System.out.println(--op + op--);
}
System.out.println(op);

VI. Re-write the following using Ternary Operator String


s=””;
switch(input)
{
case ‘A’: s=”Alexander”; break;
case ‘F’: s=”Franklin”; break;
default: s=”Unknown”;
}
VII. Analyze how many times the following loops gets executed and what is
the output:

1. int a=12;
while(true)
{
a=a/2;
a=a*2;
a-=2;
System.out.println(a++);
if(a%2==0)
break;
}

2. int x=1,y=1,z=0;
do
{
for(;(x+y)<=5;)
{
System.out.println(x+" "+y);
x++;
++y;
}
z++;
} while(z<=2);

VIII. Write the Output


1. System.out.println (Character.isUpperCase (Character.toUpperCase (‘a’)));

2. System.out.println (Integer.valueOf (“10”) %Integer.valueOf (“5”));

IX. Write function prototypes


1. A function named Calc which accepts two integer arguments and returns
the sum.
2. A function named ASCII which accepts two character arguments and
displays the sum of the ASCII codes of the arguments.
3. A function named Shopping which accepts one String argument and an
integer argument.
void Shopping(String s, int a)
X. Write the Output
1. String s1=”Examination”;
String s2=”December-2017”
System.out.println (s1+" "+ ((Integer.valueOf (s2.substring (9)) +1)) +" March");
System.out.println (s1.endsWith(“ion”));
System.out.println (s2.replace(s2.substring(0, 3),”Nov”));
System.out.println(s1.charAt(s1.length()/2+1)+”
“+s2.charAt(s1.length()/s2.length()));
System.out.println (s1.substring (0, s1.length ()));

2. System.out.println(Math.max (Math.rint (Math.floor (8.76)), Math.min (4.5,


Math.round (5.7778))));
System.out.println(Math.ceil(Math.floor(-6.78)));
System.out.println(Math.max(Math.max(100,50), Math.min(-50, 200)));
System.out.println(Math.round(Math.abs(-9.889)));
System.out.println((int)(Math.random()*10));

XI. Write Java Statements


(a)To accept input for a String using Scanner class.
(b) To import all the classes of the package Digital to the package Music.
(c) To convert the double value as string using Wrapper class method.

You might also like