REVISION QUESTIONS FOR OOP2 JAVA
1.The Java interpreter is used for the execution of the source code.
True False
2) On successful compilation a file with the class extension is created.
a) True
b) False
3) The Java source code can be created in a Notepad editor. a)
True
b) False.
4) The Java Program is enclosed in a class definition. a)
True
b) False
5) What declarations are required for every Java application?
6) What are the two parts in executing a Java program and their purposes?
7) What are the three OOPs principles and define them?
8) What is a compilation unit?
9) What output is displayed as the result of executing the following statement?
10) In order for a source code file, containing the public class Test, to successfully compile,
which of
11) What are identifiers and what is naming convention?
12) What is the return type of program’s main( ) method?
14) Which characters are as first characters of an identifier?
15) What are different comments?
16) What is the difference between constructor method and method?
17) What is the use of bin and lib in JDK?
Data types,variables and Arrays
1) What is meant by variable?
2) What are the kinds of variables in Java? What are their uses?
3) How are the variables declared?
4) What are variable types?
5) How do you assign values to variables?
6) What is a literal? How many types of literals are there?
7) What is an array?
8) How do you declare an array?
9) Java supports multidimensional arrays. a)True
b)False
10) An array of arrays can be created.
a)True
b)False
11) What is a string?
12) Strings are instances of the class String. a)True
b)False
13) When a string literal is used in the program, Java automatically creates instances of the string
class. a)True
b)False
14) Which operator is to create and concatenate string?
15) Which of the following declare an array of string objects?
String[ ] s; String [ ]s:
String[ s]:
String s[ ]:
16) Which of the following are primitive types?
byte String integer
Float
17) What is the range of the char type?
0 to 216
0 to 215
0 to 216-1
0 to 215-1
19) What are primitive data types?
20) What are default values of different primitive types?
21) Converting of primitive types to objects can be explicitly. a)True
b)False
22) How do we change the values of the elements of the array?
23) What is final varaible?
24) What is static variable?
Operators
1) What are operators and what are the various types of operators available in Java?
2) The ++ operator is used for incrementing and the -- operator is used for
decrementing. a)True
b)False
3) Comparison/Logical operators are used for testing and magnitude. a)True
b)False.
4) Character literals are stored as unicode characters. a)True
b)False
5) What are the Logical operators?
6) What is the % operator?
7) What is the value of 111 % 13?
3
5
8) Is &&= a valid operator?
9) Can a double value be cast to a byte?
ACan a byte object be cast to a double value ?
10) What are order of precedence and associativity?
12) Which Java operator is right associativity?
13) What is the difference between prefix and postfix of -- and ++
operators?
14) What is the result of expression 5.45 + "3,2"?
The double value 8.6 The
string ""8.6" The long value
8.
The String "5.453.2"
15) What are the values of x and y ? x = 5; y = ++x;
16) What are the values of x and z? x = 5; z = x++;
Control Statements
1) What are the programming constructs?
2) class conditional {
public static void main(String args[]) {
int i = 20; int j = 55;
int z = 0;
z = i < j ? i : j; // ternary operator
System.out.println("The value assigned is " + z);
What is output of the above program?
3) The switch statement does not require a break. a)True
b)False
4) The conditional operator is otherwise known as the ternary operator. a)True
b)False
5) The while loop repeats a set of code while the condition is false. a)True
b)False
6) The do-while loop repeats a set of code atleast once before the condition is tested. a)True
b)False
7) What are difference between break and continue?
8) The for loop repeats a set of statements a certain number of times until a condition is
matched. a)True
b)False
9) Can a for statement loop indefintely?
10) What is the difference between while statement and a do statement/