Java Questions

Q:

Which of the following is not a keyword?

A) assert B) pass
C) eval D) nonlocal
 
Answer & Explanation Answer: C) eval

Explanation:

"eval" is not a keyword and is can be used as variable.

Report Error

View Answer Report Error Discuss

Filed Under: Java

19 12929
Q:

Which of the following statements are equal for a variable declared in the interface ?

1. int X=10
2. public int X=10
3. public static final int X=10

A) Only 1 and 2 are equal B) Only 2 and 3 are equal
C) All are unequal D) All are equal
 
Answer & Explanation Answer: D) All are equal

Explanation:

All the statements are equal because inside an interface a variable declared will be public static final by default 

Report Error

View Answer Report Error Discuss

Filed Under: Java
Job Role: IT Trainer

0 12713
Q:

What are the types of Collision Resolution Techniques and the methods used in each of the type?

Answer

Open addressing (closed hashing),


The methods used include: Overflow block,


 Closed addressing (open hashing)


The methods used include: Linked list, Binary tree…

Report Error

View answer Workspace Report Error Discuss

Subject: Java

16 12707
Q:

A lock can be acquired on a class.

The above statement is

A) True B) False
C) Both A and B D) None
 
Answer & Explanation Answer: A) True

Explanation:

A lock can be acquired on a class. This lock is acquired on the class's Class object.

Report Error

View Answer Report Error Discuss

Filed Under: Java

0 12041
Q:

How are this() and super() used with constructors?

Answer

Constructors use this to refer to another constructor in the same class with a different parameter list.


Constructors use super to invoke the superclass's constructor. If a constructor uses super, it must use it in the first line; otherwise, the compiler will complain.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

1 11273
Q:

Can you give few examples of final classes defined in Java API?

Answer

java.lang.String,  java.lang.Math are final classes.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

6 8040
Q:

If you are using C language to implement the heterogeneous linked list, what pointer type will you use?

Answer

The heterogeneous linked list contains different data types in its nodes and we need a link, pointer to connect them. It is not possible to use ordinary pointers for this. So we go for void pointer. Void pointer is capable of storing pointer to any type as it is a generic pointer type.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 7826
Q:

Should a main() method be compulsorily declared in all java classes?

Answer No not required. main() method should be defined only if the source class is a java application.
Report Error

View answer Workspace Report Error Discuss

Subject: Java

10 7790