Java Questions

Q:

I want to print "Hello" even before main() is executed. How will you acheive that?

Answer Print the statement inside a static block of code. Static blocks get executed when the class gets loaded into the memory and even before the creation of an object. Hence it will be executed before the main() method. And it will be executed only once.
Report Error

View answer Workspace Report Error Discuss

Subject: Java - Technology

6 7626
Q:

Which method names follow the JavaBeans standard?

A) addSize B) putDimensions
C) getCust D) deleteRep
 
Answer & Explanation Answer: C) getCust

Explanation:

C use the valid prefixes 'get' and 'is

Report Error

View Answer Report Error Discuss

Filed Under: Java - Technology

0 7107
Q:

What are the restriction imposed on a static method or a static block of code?

Answer A static method should not refer to instance variables without creating an instance and cannot use "this" operator to refer the instance.
Report Error

View answer Workspace Report Error Discuss

Subject: Java - Technology

5 6238
Q:

Which of the following are incorrect form of StringBuffer class constructor  ?

A) StringBuffer(int size , String str) B) StringBuffer(int size)
C) StringBuffer(String str) D) StringBuffer()
 
Answer & Explanation Answer: A) StringBuffer(int size , String str)

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: Java - Technology
Job Role: Database Administration , IT Trainer

3 6029
Q:

In RDBMS, what is the efficient data structure used in the internal storage representation?

A) Stack B) Queue
C) B+ tree structure D) AVL tree Structure
 
Answer & Explanation Answer: C) B+ tree structure

Explanation:

B+ tree. Because in B+ tree, all the data is stored only in leaf nodes, that makes searching easier. This corresponds to the records that shall be stored in leaf nodes

Report Error

View Answer Report Error Discuss

Filed Under: Java - Technology

0 6019
Q:

Which two method you need to implement for key Object in HashMap ?

Answer

In order to use any object as Key in HashMap, it must implements equals and hashcode method in Java.

Report Error

View answer Workspace Report Error Discuss

4 5834
Q:

Which of these class have only one field 'TYPE' ?

A) Run time B) Process
C) Void D) System
 
Answer & Explanation Answer: C) Void

Explanation:

The Void class has one field, TYPE, which holds a reference to the Class object for the type void.

Report Error

View Answer Report Error Discuss

Filed Under: Java - Technology
Job Role: Analyst , IT Trainer

6 5749
Q:

Which is true?

A) "X extends Y" is correct if and only if X is a class and Y is an interface B) "X extends Y" is correct if and only if X is a class and Y is an interface
C) "X extends Y" is correct if X and Y are either both classes or both interfaces D) "X extends Y" is correct for all combinations of X and Y being classes and/or interfaces
 
Answer & Explanation Answer: C) "X extends Y" is correct if X and Y are either both classes or both interfaces

Explanation:

A is incorrect because classes implement interfaces, they don't extend them. B is incorrect because interfaces only "inherit from" other interfaces. D is incorrect based on the preceding rules.

Report Error

View Answer Report Error Discuss

Filed Under: Java - Technology

2 5562