Placement papers on Java - Set 1

Placement papers on Java - Set 1


1. What will happen when you attempt to compile and run this code?

public class MyMain
{
public static void main(String argv)
{
System.out.println("Hello world");
}
}

The compiler will complain that main is a reserved word and cannot be used for a class
The code will compile and when run will print out "Hello world"
The code will compile but will complain at run time that no constructor is defined
The code will compile but will complain at run time that main is not correctly defined
View Answer / Hide Answer

ANSWER: The code will compile but will complain at run time that main is not correctly defined




2. Which of the following are not Java modifiers?

public
private
friendly
transient
View Answer / Hide Answer

ANSWER: friendly




3. Why might you define a method as native?

To get to access hardware and language (c/c++) that Java does not know about
To define a new data type such as an unsigned integer
To write local method which can not be executed remotely
To overcome the limitation of the private scope of a method
View Answer / Hide Answer

ANSWER: To get to access hardware and language (c/c++) that Java does not know about




4. You want to loop through an array and stop when you come to the last element. Being a good java programmer and forgetting everything you ever knew about C/C++ you know that arrays contain information about their size. Which of the following can you use?

myarray.length();
myarray.length;
myarray.size
myarray.size();
View Answer / Hide Answer

ANSWER: myarray.length;




5. How do you indicate where a component will be positioned using Flowlayout?

North, South,East,West
Assign a row/column grid reference
Pass a X/Y percentage parameter to the add method
Do nothing, the FlowLayout will position the component
View Answer / Hide Answer

ANSWER: Do nothing, the FlowLayout will position the component




6. How do you change the current layout manager for a container

Use the setLayout method
Once created you cannot change the current layout manager of a component
Use the setLayoutManager method
Use the updateLayout method
View Answer / Hide Answer

ANSWER: Use the setLayout method




7. Which of the following are not fields of the GridBagConstraints class?

ipadx
fill
insets
width
View Answer / Hide Answer

ANSWER: width




8. Which statements are correct about the anchor field?

It is a field of the GridBagLayout manager for controlling component placement
It is a field of the GridBagConstraints class for controlling component placement
A valid setting for the anchor field is GridBagConstraints.SOUTH
The anchor field controls the height of components added to a container
View Answer / Hide Answer

ANSWER: It is a field of the GridBagConstraints class for controlling component placement




9. Is the following statement true or false? When using the GridBagLayout manager, each new component requires a new instance of the GridBagConstraints class.

TRUE
FALSE
View Answer / Hide Answer

ANSWER: FALSE




10. Which most closely matches a description of a Java Map?

A vector of arrays for a 2D geographic representation
A class for containing unique array elements
A class for containing unique vector elements
An interface that ensures that implementing classes cannot contain duplicate keys
View Answer / Hide Answer

ANSWER: An interface that ensures that implementing classes cannot contain duplicate keys


Post your comment

You may like