0% found this document useful (0 votes)
24 views

Class 10 Practice 8

The document contains a series of multiple-choice questions related to Java programming concepts, including data types, methods, object-oriented programming, and syntax. Each question presents four options, with topics ranging from the size of data types to specific methods and their functionalities. The questions are designed to test knowledge of Java fundamentals and programming principles.

Uploaded by

ayanacharya2009
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)
24 views

Class 10 Practice 8

The document contains a series of multiple-choice questions related to Java programming concepts, including data types, methods, object-oriented programming, and syntax. Each question presents four options, with topics ranging from the size of data types to specific methods and their functionalities. The questions are designed to test knowledge of Java fundamentals and programming principles.

Uploaded by

ayanacharya2009
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

1) The size of “int” data type is:

(a) 8 bits (b) 16 bits (c) 32 bits (d) 64 bits

2) What is the return type of a constructor?


(a) void (b) Boolean (c) int (d) None of the above

3) What is the result produced after the following statements are executed:
int a = 2,b, c;
a = a+4;
b = 3*a;
c = a-b;
System.out.println(2+c+c);
(a) 2cc (b) -22 (c) 200 (d) 22

4) a[16] is the _________ element of the array declared as char a[20];


(a) 16th (b) 15th (c) 17th (d) None of the above

5) The access specifier, return type and function signature together is known as: Function ________
(a) Prototype (b) Signature (c) Definition (d) Call

6) The default delimiter in Scanner class is:


(a) Tab character (b) Blank Character (c) All of the above (d) None of the above

7) With respect to the input “This is a cat”, what will be the values in ‘x’ and ‘y’ after the execution
of the
following statements:
String x = sc.next();
String y = sc.nextLine();
(a) x=This , y=is (b) x=This , y=is a cat (c) x=This is a , y=cat (d) None of the above
8) What is the return type of the following method: x.equals(y)
(a) yes or no (b) right or wrong (c) All of the above (d) None of the above

9) Two Arithmetic expressions can be joined with if statement, using:


(a) Logical operator (b) Null operator (c) Arithmetic operator (d) Ternary operator

10) Which of the following is not a keyword?


(a) false (b) void (c) while (d) main

11) Which of the following statement is an invalid array declaration?


(a) int [ ][ ]n; (b) int n[ ]; (c) int n[4]; (d) int n[ ][ ];

12) More than one java statements together is called block/compound statements. They are
enclosed in:
(a) Parenthesis (b) Braces (c) Square brackets (d) /* and */

13) Character function which checks whether a character is a digit or not:


(a) isLetterOrDigit() (b) isDigit() (c) Both a and b (d) None of the above

14) A class is a ______________ data type.


(a) Primitive (b) Composite (c) user-defined (d) both b and c

15) The property of OOP which is implemented through the concept of function overloading
(a) Encapsulation (b) Abstraction (c) Polymorphism (d) Modularity

16) The Java compiler translates Java programs to intermediate level language called:
(a) Machine Language (b) Byte Code (c) System Language (d) Native Executable Code

17) double c , x = 5, y=10;


int z=51;
c = x * y + z/2.5;
What is the value now stored in c?
(a) 70 (b) 40.4 (c) 70.4 (d) 152

18) Java Virtual Machine (JVM) is a:


(a) Interpreter (b) Compiler (c) Machine Code (d) Byte Code
19) If a function returns a value, the return type of the function will not be:
(a) int (b) float (c) void (d) None of the above

20) Which of the following can be used when you know the number of times we have to perform a
task:
(a) for loop (b) while loop (c) do-while loop (d) All of the above

21) What is the numerical range of a char in Java?


a) -128 to 127 b) 0 to 256 c) 0 to 32767 d) 0 to 65535

22) Which of these coding types is used for data type characters in Java?
a) ASCII b) ISO-LATIN-1 c) UNICODE d) None of the mentioned

23) Which of these values can a boolean variable contain?


a) True & False b) 0 & 1 c) Any integer value. d) Both a & b

24) Which of these occupy first 0 to 127 in Unicode character set used for characters in Java?
a) ASCII b) ISO-LATIN-1 c) None of the mentioned d) Both a & b

25) Which one is a valid declaration of a boolean?


a) boolean b1 = 1; b) boolean b2 = ‘false’; c) boolean b3 = false; d) boolean b4
= ‘true’

26) What is the stored in the object obj in following lines of code?
box obj;
a) NULL
b) Any arbitrary pointer
c) Garbage
d) Memory address of allocated memory of object.

27) Which of these keywords is used to make a class?


a) class b) struct c) int d) None of the mentioned

28) Which of the following is a valid declaration of an object of class Box?


a) Box obj = new Box();
b) Box obj = new Box;
c) obj = new Box();
d) new Box obj;

29) Which of these operators is used to allocate memory for an object?


a) malloc b) alloc c) new d) give

30) Which of these statement is incorrect?


a) Every class must contain a main() method.
b) Applets do not require a main() method at all.
c) There can be only one main() method in a program.
d) main() method must be made public.

31) What should be expression1 evaluate to in using ternary operator as in this line?
expression1 ? expression2 : expression3
a) Integer b) Floating – point numbers c) Boolean d) None of the mentioned

32) Which of the below method of the String class can be used to test string equality?
a) equals()
b) isEqual()
c) isequals()
d) equal()

33) Which of the below method of the String class can be used to find the total number of characters
in the String?
a) chars()
b) size()
c) len()
d) length()

34) 6. What would be the output of the below code related to String equality?
String s = new String("PraBhu");
String p = new String("PraBhu");
System.out.println(s == p);
a) true
b) false

35) Choose the correct output of the below code about String – Character Equality?
Character c = 'A';
String s = "A";
System.out.println(c.equals(s));
a) true
b) false

36) Method used to take a string as input in Java?


a) next()
b) nextLine()
c) Both A. and B.
d) None of these

37) Array in java is ___.


a) Collection of similar elements
b) Collection of elements of different types
c) The data type of consisting of characters
d) None of these

38) Wrapper class in java is ___.


a) Used to encapsulate primitive data types
b) Declare new classes called wrapper
c) Create a new instance of the class
d) None of these

39) Boxing is ___.


a) Creating a new box
b) Creating object
c) Converting primitive type of object instance
d) All of these

40) Which Java method is used to convert an object to string?


a) createString()
b) toString()
c) object.string()
d) newString()

You might also like