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

Class 10 MCQ Practice Paper

The document is a practice paper consisting of 40 multiple-choice questions related to Java programming concepts. It covers topics such as control statements, data types, operators, loops, and class structures. Each question includes four answer options, and the reader is prompted to fill in the correct answer.

Uploaded by

Rituraj Pradhan
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)
37 views8 pages

Class 10 MCQ Practice Paper

The document is a practice paper consisting of 40 multiple-choice questions related to Java programming concepts. It covers topics such as control statements, data types, operators, loops, and class structures. Each question includes four answer options, and the reader is prompted to fill in the correct answer.

Uploaded by

Rituraj Pradhan
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
You are on page 1/ 8

PRACTICE PAPER 1

1) In java control statements break, continue, return, try-catch-finally and assert


belongs to?
A. Selection statements
B. Loop Statements
C. Transfer statements
D. Pause Statement
Answer: _______________

2) Which provides runtime environment for java byte code to be executed?


A. JDK
B. JVM
C. JRE
D. JAVAC
Answer: _______________

3) What is byte code in Java?


A. Code generated by a Java compiler
B. Code generated by a Java Virtual Machine
C. Name of Java source code file
D. Block of code written inside a class
Answer: _______________

4) Which of the following are not Java keywords?


A. double
B. switch
C. then
D. instanceof
Answer: _______________

5) Which of these have highest precedence?


A. ()
B. ++
C. *
D. &&
Answer: _______________

6) Data type long literals are appended by _____


A. Uppercase L
B. Lowercase l
C. Long
D. Both A and B
Answer: _______________

7) Which variables are created when an object is created with the use of the
keyword 'new' and destroyed when the object is destroyed?
A. Local variables
B. Instance variables
C. Class Variables
D. Static variables
Answer: _______________

8) Which one is a template for creating different objects ?


A. An Array
B. A class
C. Interface
D. Method
Answer: _______________

9) Which symbol is used to contain the values of automatically initialized arrays?


A. Brackets
B. Braces
C. Parentheses
D. Comma
Answer: _______________

10) Which of these operators is used to allocate memory to array variable in


Java?
A. alloc
B. malloc
C. new malloc
D. new
Answer: _______________

11) Which of these is returned by Greater Than, Less Than and Equal To (i.e
Relational) operator ?
A. Float
B. Integer
C. Boolean
D. Double
Answer: _______________

12) Which statement transfer execution to different parts of your code based on
the value of an expression?
A. If
B. Switch
C. Nested-if
D. if-else-if
Answer: _______________

13) Modulus operator (%) can be applied to which of these?


A. Integers
B. Floating - point numbers
C. Both A and B
D. None of These
Answer: _______________

14) Division operator has ____ precedence over multiplication operator


A. Heighest
B. Least
C. Equal
D. None of These
Answer: _______________

15) What is the full form of JVM ?


A. Java Very Large Machine
B. Java Verified Machine
C. Java Very Small Machine
D. Java Virtual Machine
Answer: _______________

16) In Java code, the line that begins with /* and ends with */ is known as?
A. Multiline comment
B. Single line comment
C. Both A & B
D. None of these
Answer: _______________

17) Write the output:


char ch = 'F';
int m = ch;
m=m+5;
System.out.println(m + " " + ch);
A. 107 F
B. K F
C. 75 F
D. None of these
Answer: _______________

18) Write the output of the following statement:


System.out.println("A picture is worth \t \"A thousand words.\" ");
A. A picture is worth A thousand words.
B. A picture is worth “A thousand words.”
C. A picture is worth “A thousand words.”
D. Error
Answer: _______________

19) It is compulsory to return a value from a function.


A. True
B. False
Answer: _______________

20) A function in Java can be written


A. Inside a class
B. Outside a class
C. Inside a main() function
D. None of these
Answer: _______________

21) An overloaded function is


A. A function with same name but different return types
B. A function with same name but different number of parameters
C. A function with same name but different type of parameters
D. Both B and C
Answer: _______________

22) Which of the following is a valid declaration of a char?


A. char ch = '\utea';
B. char ca = 'tea';
C. char cr = \u0223;
D. char cc = '\itea';
Answer: _______________

23) Evaluate the following Java expression, if x=3, y=5, and z=10:
++z + y - y + z + x++
A. 24
B. 23
C. 20
D. 25
Answer: _______________

24) Which of the following for loop declaration is not valid?


A. for ( int i = 99; i >= 0; i / 9 )
B. for ( int i = 7; i <= 77; i += 7 )
C. for ( int i = 20; i >= 2; - -i )
D. for ( int i = 2; i <= 20; i = 2* i )
Answer: _______________

25) Given that Student is a class, how many reference variables and objects are
created by the following code?
Student studentName, studentId;
studentName = new Student();
Student stud_class = new Student();
A. Three reference variables and two objects are created.
B. Two reference variables and two objects are created.
C. One reference variable and two objects are created.
D. Three reference variables and three objects are created.
Answer: _______________

26) Which statement is true about Java?


A. Java is a sequence-dependent programming language
B. Java is a code dependent programming language
C. Java is a platform-dependent programming language
D. Java is a platform independent programming language
Answer: _______________

27) What will be the output of the following Java program?


class evaluate
{
public static void main(String args[])
{
int arr[] = new int[] {0 , 1, 2, 3, 4, 5, 6, 7, 8, 9};
int n = 6;
n = arr[arr[n] / 2];
System.out.println(arr[n] / 2);
}
}
A. 2
B. 1
C. 4
D. 0
Answer: _______________

28) What is the extension of compiled java classes?


A. .txt
B. .js
C. .class
D. .java
Answer: _______________

29) What will be the output of the following Java code?


class Output
{
public static void main(String args[])
{
double x = 3.14;
int y = (int) Math.ceil(x);
System.out.print(y);
}
}
A. 3
B. 0
C. 4
D. 3.0
Answer: _______________

30) Find the output of the following


int a[ ]={3,2,15,16,18};
int i=a[1];
int n=a[2]++;
int m=a[i++];
System.out.println(i+”\t “+n+”\t “+m);
A. 2 15 16
B. 2 16 15
C. 3 15 16
D. 3 16 15
Answer: _______________

31) Given a class Student described as below:


Data Members/instance variables:
String name
int m1, m2, m3 , max, avg;
Member methods:
constructor to initialize the data members with the default parameters.
accept() To input the student details.
compute() To compute the maximum out of three marks and the average
marks.
display() To display the details of the student.
Write a main method to create object of a class and call the member methods.
class _____ 1________
{
String name;
int m1, m2, m3, max;
________2_________
{
name=””;
m1=m2=m3=max=avg=0;
}
void accept()
{
Scanner sc=new Scanner(System.in);
name=sc.nextLine();
m1=sc.nextInt();
m2=sc.nextInt();
m3=sc.nextInt();
}
_____3_____ compute()
{
max = _________ 4________;
avg=(m1+m2+m3)/3;
}
void display()
{
System.out.println(name);
System.out.println(m1+”\t”+m2+”\t”+m3);
System.out.println(max);
System.out.println(avg);
}
static void main()
{
Student obj= new Student();
_______5__________;
obj.display();
}
}

1)
A. Student()
B. Student
C. student
D. Student;
Answer: _______________
2)
A. Student
B. Student();
C. Student()
D. student();
Answer: _______________

3)
A. Void
B. void
C. int
D. float
Answer: _______________

4)
A. Math.max(m1,m2,m3);
B. Math.max(m1,Math.max(m2,m3));
C. Math.max(m1,Math.max(m2,m3));
D. Math.max(m1;m2;m3);
Answer: _______________

5)
A. obj.compute();
B. obj.compute;
C. obj.calculate();
D. Obj.compute();
Answer: _______________

32) Read the following program and answer the questions given below
class Method
{
double compute(int a, int b)
{
return (a+b)/2.0;
}
static void main()
{
Method ob=new Method():
_______A______;
}
}
Which of the following statements will correctly invoke the method compute() in
line ‘A’;
A. System.out.println(ob.compute(15));
B. ob.compute(15,19);
C. ob.compute();
D. System.out.println(ob.compute(15,19));
Answer: _______________

33) Which of the following statements is not the correct way to declare
overloaded methods.
A. void area(int x)
B. void area(float x)
C. int area(int x)
D. void area(double x)
Answer: _______________

34) What will be the output of the following Java code?


class overload
{
int x;
double y;
overload()
{
this.x = 0;
this.y = 0;
}
void add(int a , int b)
{
x = a + b;
}
void add(double c , double d)
{
y = c + d;
}
public static void main(String args[])
{
overload obj = new overload();
int a = 2;
double b = 3.2;
obj.add(a, a);
obj.add(b, b);
System.out.println(obj.x + " " + obj.y);
}
}
A. 6.4 6.4
B. 6 6
C. 4 6.4
D. 6.4 6
Answer: _______________

35) Every loop in Java has a condition that should be ___ in order to proceed for
execution.
A. FALSE
B. TRUE
Answer: _______________

36) A WHILE loop in Java executes the statements at least once even the
condition is not satisfied.
A. FALSE
B. TRUE
Answer: _______________

37) A FOR loop in Java generally contains a Loop-Counter variable.


A. FALSE
B. TRUE
Answer: _______________

38) What is the output of the below Java program with WHILE, BREAK and
CONTINUE?
int cnt=0;
while(true)
{
if(cnt > 4)
break;
if(cnt==0)
{
cnt++;
continue;
}
System.out.print(cnt + ",");
cnt++;
}
A. 0,1,2,3,4,
B. 1,2,3,4,
C. 1,2,3,4
D. Compiler error
Answer: _______________

39) What is the main difference between a WHILE and a DO-WHILE loop in Java?
A. WHILE loop executes the statements inside of it at least once even if the
condition is false.
B. DO-WHILE loop executes the statements inside of it at least once even if the
condition is false.
C. WHILE loop is fast.
D. DO-WHILE loop is fast.
Answer: _______________

40) What is the output of the below Java code?


int score=1;
for(; true; score++)
{
System.out.print(score +",");
if(score > 3)
break;
}
A. 1,2,3,
B. 1,2,3
C. 1,2,3,4,
D. 1,2,3,4
Answer: _______________

You might also like