PRO192.Part6

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

d

1. What is the return type of Constructors? a) int b) float c) void d) None of the mentioned

c

10. What is the output of this program? class area { int width; int length; int area; void area(int width, int length) { this.width = width; this.length = length; } } class Output { public static void main(String args[]) { area obj = new area(); obj.area(5 , 6); System.out.println(obj.length + " " + obj.width); } } a) 0 0 b) 5 6 c) 6 5 d) 5 5

d

2. Which keyword is used by method to refer to the object that invoked it? a) import b) catch c) abstract d) this

a

5. Which function is used to perform some action when the object is to be destroyed? a) finalize() b) delete() c) main() d) None of the mentioned

d

On applying Left shift operator, <<, on an integer bits are lost one they are shifted past which position bit? a) 1 b) 32 c) 33 d) 31

a

Decrement operator, −−, decreases value of variable by what number? a) 1 b) 2 c) 3 d) 4

d

What is the output of this program? class leftshift_operator { public static void main(String args[]) { byte x = 64; int i; byte y; i = x << 2; y = (byte) (x << 2) System.out.print(i + " " + y); } } a) 0 64 b) 64 0 c) 0 256 d) 256 0

c

What is the output of this program? class operators { public static void main(String args[]) { int var1 = 5; int var2 = 6; int var3; var3 = ++ var2 * var1 / var2 + var2; System.out.print(var3); } } a) 10 b) 11 c) 12 d) 56

d

What is the output of this program? class operators { public static void main(String args[]) { int x = 8; System.out.println(++x * 3 + " " + x); } } a) 24 8 b) 24 9 c) 27 8 d) 27 9

b

What is the output of this program? class rightshift_operator { public static void main(String args[]) { int x; x = 10; x = x >> 1; System.out.println(x); } } a) 10 b) 5 c) 2 d) 20

b

What is the output of this program? class selection_statements { public static void main(String args[]) { int var1 = 5; int var2 = 6; if ((var2 = 1) == var1) System.out.print(var2); else System.out.print(++var2); } } a) 1 b) 2 c) 3 d) 4

d

What is the output of this program? class Output { public static void main(String args[]) { final int a=10,b=20; while(a<b) { System.out.println("Hello"); } System.out.println("World"); } } a) Hello b) run time error c) Hello world d) compile time error

c

What is the output of this program? class Output { public static void main(String args[]) { int a,b,c,d; a=b=c=d=20 a+=b-=c*=d/=20 System.out.println(a+" "+b+" "+c+" "+d); } } a) compile time error b) runtime error c) a=20 b=0 c=20 d=1 d) none of the mentioned

d

What is the output of this program? class Output { public static void main(String args[]) { int x=y=z=20; } } a) compile and runs fine b) 20 c) run time error d) compile time error

d

What is the value stored in x in following lines of code? int x, y, z; x = 0; y = 1; x = y = z = 8; a) 0 b) 1 c) 9 d) 8

c

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

d

3. Which of the following is a method having same name as that of its class? a) finalize b) delete c) class d) constructor

d

4. Which operator is used by Java run time implementations to free the memory of an object when it is no longer needed? a) delete b) free c) new d) None of the mentioned

b

6. What is the output of this program? class box { int width; int height; int length; int volume; box() { width = 5; height = 5; length = 6; } void volume() { volume = width*height*length; } } class constructor_output { public static void main(String args[]) { box obj = new box(); obj.volume(); System.out.println(obj.volume); } } a) 100 b) 150 c) 200 d) 250

a

7. What is the output of this program? class San { San()throws IOException { } } class Foundry extends San { Foundry() { } public static void main(String[]args) { } } a) compile time error b) run time error c) compile and runs fine d) unreported exception java.io.IOException in default constructor

a

8. What is the output of this program? class box { int width; int height; int length; int volume; void finalize() { volume = width*height*length; System.out.println(volume); } protected void volume() { volume = width*height*length; System.out.println(volume); } } class Output { public static void main(String args[]) { box obj = new box(); obj.width=5; obj.height=5; obj.length=6; obj.volume(); } } a) 150 b) 200 c) Run time error d) Compilation error

c

9. Which of the following statements are incorrect? a) default constructor is called at the time of object declaration b) Constructor can be parameterized c) finalize() method is called when a object goes out of scope and is no longer needed d) finalize() method must be declared protected

a

Can 8 byte long data type be automatically type cast to 4 byte float data type? a) True b) False

c

Modulus operator, %, can be applied to which of these? a) Integers b) Floating - point numbers c) Both Integers and floating - point numbers. d) None of the mentioned

a

What is the order of precedence (highest to lowest) of following operators? 1. & 2. ^ 3. ?: a) 1 -> 2 -> 3 b) 2 -> 1 -> 3 c) 3 -> 2 -> 1 d) 2 -> 3 -> 1

a

What is the output of this program? class Modulus { public static void main(String args[]) { double a = 25.64; int b = 25; a = a % 10; b = b % 10; System.out.println(a + " " + b); } } a) 5.640000000000001 5 b) 5.640000000000001 5.0 c) 5 5 d) 5 5.640000000000001

a

What is the output of this program? class Output { public static void main(String args[]) { int a = 1; int b = 2; int c = 3; a |= 4; b >>= 1; c <<= 1; a ^= c; System.out.println(a + " " + b + " " + c); } } a) 3 1 6 b) 2 2 3 c) 2 3 4 d) 3 3 6

d

What is the output of this program? class Output { public static void main(String args[]) { int a = 1; int b = 2; int c; int d; c = ++b; d = a++; c++; b++; ++a; System.out.println(a + " " + b + " " + c); } } a) 3 2 4 b) 3 2 3 c) 2 3 4 d) 3 4 4

d

What is the output of this program? class Output { public static void main(String args[]) { int a = 5; int b = 10; first: { second: { third: { if (a == b >> 1) break second; } System.out.println(a); } System.out.println(b); } } } a) 5 10 b) 10 5 c) 5 d) 10

c

What is the output of this program? class bitwise_operator { public static void main(String args[]) { int var1 = 42; int var2 = ~var1; System.out.print(var1 + " " + var2); } } a) 42 42 b) 43 43 c) 42 -43 d) 42 43

a

What is the output of this program? class bitwise_operator { public static void main(String args[]) { int a = 3; int b = 6; int c = a | b; int d = a & b; System.out.println(c + " " + d); } } a) 7 2 b) 7 7 c) 7 5 d) 5 2

b

What is the output of this program? class comma_operator { public static void main(String args[]) { int sum = 0; for (int i = 0, j = 0; i < 5 & j < 5; ++i, j = i + 1) sum += i; System.out.println(sum); } } a) 5 b) 6 c) 14 d) compilation error

c

What is the output of this program? class increment { public static void main(String args[]) { double var1 = 1 + 5; double var2 = var1 / 4; int var3 = 1 + 5; int var4 = var3 / 4; System.out.print(var2 + " " + var4); } } a) 1 1 b) 0 1 c) 1.5 1 d) 1.5 1.0

c

What is the output of this program? class increment { public static void main(String args[]) { int g = 3; System.out.print(++g * 8); } } a) 25 b) 24 c) 32 d) 33

c

What is the output of this program? class jump_statments { public static void main(String args[]) { int x = 2; int y = 0; for ( ; y < 10; ++y) { if (y % x == 0) continue; else if (y == 8) break; else System.out.print(y + " "); } } } a) 1 3 5 7 b) 2 4 6 8 c) 1 3 5 7 9 d) 1 2 3 4 5 6 7 8 9

d

Which of the following can be operands of arithmetic operators? a) Numeric b) Boolean c) Characters d) Both Numeric & Characters

a

Which of the following loops will execute the body of loop even when condition controlling the loop is initially false? a) do-while b) while c) for d) None of the mentioned

a

Which of these are selection statements in Java? a) if() b) for() c) continue d) break

a

Which of these have highest precedence? a) () b) ++ c) * d) >>

d

Which of these is not a bitwise operator? a) & b) &= c) |= d) <=

d

Which of these jump statements can skip processing remainder of code in its body for a particular iteration? a) break b) return c) exit d) continue

c

Which of these lines of code will give better performance? 1. a | 4 + c >> b & 7; 2. (a | ((( 4 * c ) >> b ) & 7 )) a) 1 will give better performance as it has no parentheses. b) 2 will give better performance as it has parentheses. c) Both 1 & 2 will give equal performance. d) Dependent on the computer system.

b

Which of these selection statements test only for equality? a) if b) switch c) if & switch d) None of the mentioned

b

Which of these statement is incorrect? a) switch statement is more efficient than a set of nested ifs. b) two case constants in the same switch can have identical values. c) switch statement can only test for equality, whereas if statement can evaluate any type of boolean expression. d) it is possible to create a nested switch statements.

d

Which of these statements are incorrect? a) Assignment operators are more efficiently implemented by Java run-time system than their equivalent long forms. b) Assignment operators run faster than their equivalent long forms. c) Assignment operators can be used only with numeric and character data type. d) None

c

Which of these statements are incorrect? a) Equal to operator has least precedence. b) Brackets () have highest precedence. c) Division operator, /, has higher precedence than multiplication operator. d) Addition operator, +, and subtraction operator have equal precedence. View Answer

d

Which of these statements are incorrect? a) The left shift operator, <<, shifts all of the bits in a value to the left specified number of times. b) The right shift operator, >>, shifts all of the bits in a value to the right specified number of times. c) The left shift operator can be used as an alternative to multiplying by 2. d) The right shift operator automatically fills the higher order bits with 0.

a

Which operator is used to invert all the digits in binary representation of a number? a) ~ b) <<< c) >>> d) ^

b

Which right shift operator preserves the sign of the value? a) << b) >> c) <<= d) >>=

c

With x = 0, which of the following are legal lines of Java code for changing the value of x to 1? 1. x++; 2. x = x + 1; 3. x += 1; 4. x =+ 1; a) 1, 2 & 3 b) 1 & 4 c) 1, 2, 3 & 4 d) 3 & 2


Ensembles d'études connexes

Chapter 7. Control of Gene Expression

View Set

Chapter 13 SmartBook - MGMT 3000

View Set

Laboratory Animal Technician certification

View Set

PHARM - GI/GU practice questions

View Set

Ch. 32, 33, 34 Module 12 - patho

View Set

NURS 309 Quiz 9 - Acute Type 2 Diabetes

View Set