0% found this document useful (0 votes)
101 views8 pages

Class 10 Java Practice Questions

The document contains a practice question set for Class 10 Computer Applications, featuring multiple-choice questions focused on Java programming concepts, syntax, and methods. It includes questions on data types, control structures, object-oriented programming features, and specific Java functions. Additionally, there are open-ended questions requiring code writing and explanation of programming concepts.

Uploaded by

Shreyash Pandey
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
101 views8 pages

Class 10 Java Practice Questions

The document contains a practice question set for Class 10 Computer Applications, featuring multiple-choice questions focused on Java programming concepts, syntax, and methods. It includes questions on data types, control structures, object-oriented programming features, and specific Java functions. Additionally, there are open-ended questions requiring code writing and explanation of programming concepts.

Uploaded by

Shreyash Pandey
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

computer application

CLASS 10 PRACTICE QUESTION

Question 1 [20]

Choose the correct answers to the questions from the given options. (Do not copy the
question, Write the correct answer only.)
(i) Name the feature of Java depicted in the following picture.

(a) Data Abstraction (b) Encapsulation (c) Inheritance (d) Polymorphism


(ii) The method of Scanner class to accept a 64-bit floating point number is:
(a) nextInt() (b) nextLong() (c) nextFloat() (d) nextDouble()
(iii) Classes, interfaces, methods, packages and variables are together called:
(a) Keywords (b) Identifiers (c) User defined words (d) None of the these
(iv) The keyword that makes a variable constant is:
(a) int (b) switch (c) final (d) All of these
(v) A loop programmed within another loop is known as:
(a) Null loop (b) Nested loop (c) Void body loop (d) All of these
(vi) Identify the valid keyword:
(a) For (b) INTEGER (c) case (d) elseif
(vii) Predict the output:
System.out.println(‘B’ + 2);

(a) 100 (b) B2 (c) 1002 (d) 68

Page 1 of 8
computer application

(viii) The feature of OOP implemented by Method overloading is:

(a) Inheritance (b) Polymorphism (c) Encapsulation (d) Data abstraction


(ix) Identify the output of code:
int j = 5;
for(; j <= 8;)
{ System.out.print(j + “ # ”);
j++; }
(a) Syntax error (c) A=1 B = 2
(b) # 5 # 6 # 7 # 8 (d) A = 1 B = 1
(x) The function used to convert a String value to double data type is :
a. Double.toDouble() c. Double.parseDouble()
b. Double.toString() d. String.parseDouble()

(xi) What will be the data type of variable s in the following statement?

_______ s = “Major”. starts With(“M”);

(a) int (b) char (c) String (d) boolean


(xii) The number of bytes occupied by an array of double type with 5
elements is:
(a) 10 (b) 20 (c) 40 (d) 50
(xiii) What value will be returned by compareTo( ) method if the invoking string is smaller
than the compared string?
a. A positive number c. The invoking string
b. A negative number d. Zero
(xiv) How many times will the following loop be executed and what will be the output?
int i;
for ( i=5 ; i>10 ; i++ )
System.out.print(i);
system.out.println(i * 4);

Page 2 of 8
computer application

a) 5 times, o/p 5678940


b) 0 times, o/p 20
c) 1 time, o/p 524

d) 5 times, o/p 567891

(xv) Assertion (A): To call abs() method no object or class name is required.

Reason (R): All methods of Math class are class methods.

(a) Both Assertion (A) and Reason (R) are true and Reason
(R) is a correct explanation of Assertion (A)
(b) Both Assertion (A) and Reason (R) are true and Reason (R) is
not a correct explanation of Assertion (A)
(c) Assertion (A) is false and Reason (R) is true

(d) Assertion (A) is true and Reason (R) is false

(xvi) Go through the following text and choose the correct answer:

Selection statements help in selecting one alternative out of more than


one option. They are also called decision-making statements as the
computer needs to take a decision while executing these statements as
per the conditions provided. The output of the program depends upon
the statement selected by the computer based on the validity of the
condition.

Selection statements are used to:

(a) Check conditions (b) take


decision

(c) Select an alternative of many statements (d) All of these

(xvii) Assertion (A): An array variable is also known as subscripted

Page 3 of 8
computer application

variable. Reason (R): In arrays, every element is represented with the


help of its individual index. (a) Both Assertion (A) and Reason (R) are
true and Reason (R) is a correct explanation of Assertion (A)
(b) Both Assertion (A) and Reason (R) are true and Reason (R) is
not a correct explanation of Assertion(A)
(c) Assertion (A) is true and Reason (R) is false
(d) Assertion (A) is false and Reason (R) is true
(xviii) The value of variable r in the following statement will be:
double r = Math.ceil (28.5);

(a) 28 (b) 28.0 (c) 29 (d) 29.0

(xix) The variable to access the 10th element of an array a[ ] is:

(a) a[9] (b) a[10] (c) a[11] (d) a[0]

(xx) boolean b[ ] = {true, false};

System.out.println (b[1] * 2);

What will be the output of the above code fragment ?


(a) 2 (b) 0 (c) true * false (d) Syntax error
(xxi) A method can return ………
(a) 1 value (b) 2 values (c) 3 values (d) any number of values
(xxii) In Java a constructor with no parameter is called a
(a)Default constructor (b)user defined constructor
(c)custom constructor (d)static constructor
(xxiii) Private function is accessible to......
(a)Own class only (b)sub class and class in the same package
(c)subclass (d)none of these.
(xxiv) Function prototype means
(a)Return value of a function (b)Name of a function
(c)Return type of a function (d)Return type, name and argument of a
function.
(xxv) Which of the following represent the constructor of the ABC class

Page 4 of 8
computer application

(a)ABC() (b)ABC (c)ABCconstructor (d)Constructor


ABC ()
(xxvi) What is the return type of indexOf() function of string class?
(a)char (b) String (c)boolean (d)int
(xxvii) The ability of a method or object to take on multiple forms is called.
(a) abstraction (b) encapsulation (c)inheritance (d)polymorphism
(xxviii)Which of the following is a keyword?
(a) token (b) continue (c) constant (d) all of these
(xxix) Name the method used to convert String value into int?
(a) ParseInt() (b) parseInt (c) parseInteger (d) none
of these
(xxx) The ……… allows a class to use property of another class.
(a) Encapsulation (b) Abstraction (c) inheritance (d) None
of these
(xxxi) The ……… operator is used to access method of a class.
(a) Object (b) new (c) (.)dot (d) import
(xxxii) The statement System.out.println(1+2+“four ”+2+5); gives the output………
(a)3 four 5 (b)3 four 23 (c) 12 four 23 (d) error
(xxxiii)x + = x++ + --x + --x + x; [ x = 5 ]
(a) 23 (b) 20 (c) 18 (d) none of these
(xxxiv) Math.pow(Math.ceil(4.22), Math.cbrt(8));
(a) 16 (b) 25 (c) 25.0 (d)16.0
(xxxv) Consider the following String array and give the output:
String arr[ ]={"Java", "PHP", "Python", ".Net", "HTML"};
System.out.print( arr[2].charAt(2)+” “+arr[3].indexOf(‘N’));
(a) h -1 (b) H 1 (c) t 1 (d) Runtime Error
(xxxvi) Predict the output of the following statement:
String wd[ ] = {"INDIA", "USA", "NEPAL", "GERMANY", "MEXICO"};
System.out.println(wd[2].substring(0,3) + wd[4].substring(4));
(a) USANY (b) MEXPAL (c) NEPCO (d) INDNY
(xxxvii) The return data type of Integer.parseInt( ) method is ________ .
(a) String (b) int (c) void (d) Integer
(xxxviii) Which of the following is not a type of inheritance?
(a) multiple (b) double (c) hybrid (d) single
(xxxix) Corresponding wrapper class of the char data type is?
(a) String (b) Character (c) Char (d) CHARACTER
(xl) The process to change one data type value to another data type is known as
(a)Declaration (b)Type conversion (c) Converting data type (d)Initialising data
type

Page 5 of 8
computer application

Question 2 [10X2=20]
(i) Write a Java statement for the following mathematical expression:
a2 +b2 x (a+b)8
|a + b|

(ii) Evaluate the following expression when a = 4:

a = – –a + a++ * a– – ;
(iii) Identify the syntax error in the following code fragment and rewrite
its rectified form:
for(int i=2; i++;)
{

System.out.println(i);

(iv) State the purpose of continue statement.

(v) Write down the return data type of nextLong() and Math.random()
methods.

(vi) Study the following iterative structure and answer the questions with
working:

int k = 3;
while(++k<=10)

if((k+5) % 5==0)

break;

System.out.println(k+5);

}
Page 6 of 8
computer application

(a) How many times will the loop get executed ?

(b) What will be the output ?


(vii) int x [ ] = { 8 , 5 , 2 , 9 , 4};
int k = x.length;
int la=x[0],lo=x[0];
for( int j = 0;j < k ; j++)
{ if(la> x[ j ] )
la = x[ j ];
if(lo < x[ j ] )
lo = x[ j ];
} System.out.println(“ values are ” + la + ‘ ’ + ‘ ’+ lo);
(viii) State the output of following code:
String a =“Smartphone” , b=“Graphic Art”;
String h = a.substring(2,5);
String k = b.substring(8),toUpperCase( );
System.out.println(h);
System.out.println(k.equalsIgnoreCase(h));

(ix) Predict the output:

(a) “ARTIFICIAL”.endsWith(“AL”);
(b) “Java_Basics”.trim().length();

(x) int a [ ]={ 1, 5, 6, 8, 5 };

int b[ ]={ 0, 3, 7, 3 };

Place all the elements of array b and a in another array c one after the
other and answer the questions:

(a) What will be the size of the array c ?


(b) Find the output: System.out.println(Math.pow(c[6], c[0]));

Page 7 of 8
computer application

Question 3
(i) Define method overloading?
(ii) Write an expression in Java for
√3 a+b – b
3a
(iii) State any two differences between user defined data type and primitive data
type?
(iv) What is the difference between class variable and instance variable?
int x =20, y = 10, z;
What is the value of x, y, z in
z = ++x * (y – –) %4 – y++*4/--x
Show the steps.
(v) What is the purpose of default in a switch?
(vi) What will be the output of the following code?
String s = “Java is Best”;
System.out.println(s.indexOf(‘A’))
System.out.println(s.charAt(5)+5)

(vii) What do mean by arrays?


(viii) What is the significance of using isDigit() function of Character class?
(ix) Write the Syntax to creating String implicitly and explicitly.
(x) State the output of the following code segment.
char ch;
int x=65;
do
{
ch=(char) x;
System.out.print(ch+ “ “);
if(x%11==0)
break;
x+=2;
}while(x<120);

Page 8 of 8

You might also like