Java Language | 20 Minute‐Test 7


Instruction

  • Total number of questions : 20.
  • Time alloted : 20 minutes.
  • Each question carry 1 mark.
  • No Negative marks
  • DO NOT refresh the page.
  • All the best :-).

1.

An expression involving byte, int, and literal numbers is promoted to which of these?

A.
int
B.
long
C.
byte
D.
float

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

An expression involving bytes, ints, shorts, literal numbers, the entire expression is promoted to int before any calculation is done.

2.

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.
ASCII and ISO-LATIN1

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

First 0 to 127 character set in Unicode are same as those of ISO-LAIN-1 and ASCII.

3.

Literal can be of which of these data types?

A.
integer
B.
float
C.
boolean
D.
all of the mentioned

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

None

4.

If an expression contains double, int, float, long, then whole expression will promoted into which of these data types?

A.
long
B.
int
C.
double
D.
float

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

If any operand is double the result of expression is double.

5.

Which of these is an incorrect Statement?

A.
It is necessary to use new operator to initialize an array.
B.
Array can be initialized using comma separated expressions surrounded by curly braces.
C.
Array can be initialized when they are declared.
D.
None of the mentioned

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

Array can be initialized using both new and comma separated expressions surrounded by curly braces example : int arr[5] = new int[5]; and int arr[] = { 0, 1, 2, 3, 4};

6.

Decrement operator, −−, decreases value of variable by what number?

A.
1
B.
2
C.
3
D.
4

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

None.

7.

Which right shift operator preserves the sign of the value?

A.
<<
B.
>>
C.
<<=
D.
>>=

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

None.

8.

Which of these operators can skip evaluating right hand operand?

A.
!
B.
|
C.
&
D.
&&

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

Operator short circuit and, &&, and short circuit or, ||, skip evaluating right hand operand when output can be determined by left operand alone.

9.

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

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

None.

10.

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

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

None.

11.

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

A.
malloc
B.
alloc
C.
new
D.
give

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

Operator new dynamically allocates memory for an object and returns a reference to it. This reference is address in memory of the object allocated by new.

12.

Which method can be defined only once in a program?

A.
main method
B.
finalize method
C.
static method
D.
private method

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

main() method can be defined only once in a program. Program execution begins from the main() method by java’s run time system.

13.

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

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

Java handles deallocation of memory automatically, we do not need to explicitly delete an element. Garbage collection only occurs during execution of the program. When no references to the object exist, that object is assumed to be no longer needed, and the memory occupied by the object can be reclaimed.

14.

What is the process of defining a method in terms of itself, that is a method that calls itself?

A.
Polymorphism
B.
Abstraction
C.
Encapsulation
D.
Recursion

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

None.

15.

What is the process by which we can control what parts of a program can access the members of a class?

A.
Polymorphism
B.
Abstraction
C.
Encapsulation
D.
Recursion

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

None.

16.

Which of the following statements are incorrect?

A.
static methods can call other static methods only.
B.
static methods must only access static data.
C.
static methods can not refer to this or super in any way.
D.
when object of class is declared, each object contains its own copy of static variables.

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

All objects of class share same static variable, when object of a class are declared, all the objects share same copy of static members, no copy of static variables are made.

17.

Which of these method of String class can be used to test to strings for equality?

A.
isequal()
B.
isequals()
C.
equal()
D.
equals()

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

None.

18.

Which of these is correct way of inheriting class A by class B?

A.
class B + class A {}
B.
class B inherits class A {}
C.
class B extends A {}
D.
class B extends class A {}

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

None.

19.

Which of these is correct way of calling a constructor having no parameters, of superclass A by subclass B?

A.
super(void);
B.
superclass.();
C.
super.A();
D.
super();

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

None.

20.

Which of these keywords can be used to prevent inheritance of a class?

A.
super
B.
constant
C.
Class
D.
final

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

Declaring a class final implicitly declares all of its methods final, and makes the class inheritable.

Submit your test now to view the Results and Statistics with answer explanation.