Monday, November 26, 2012

Java sample question and answer


Question 1
1.         
____ is true of a control break report.
Answer
Only a limited number of elements can be listed.
The contents can only come from one database table.
The records must be sorted by the field that will cause the break.
The report can only be run once a month.
Ans – The records must be sorted by the fields one database table

Question 2
1.         
When printing a list of employees by department, the most likely value to be examined for the control break would be the ____.
Answer
employee’s last name
employee’s department number
number of departments
number of employees processed



Ans -  employee’s department number
2 points   
Question 3
1.         
If the records are sorted by city within state, and you need totals to print by city within county within state, then a change in state causes a ____ break.
Answer
upper-level
minor-level
intermediate-level
major-level
Ans - major-level
2 points   
Question 4
1.         
When you copy data from a file on a storage device into RAM, you ____..
Answer
read from the file
close the file
open the file
write to the file
Ans - read from the file
2 points   
Question 5
1.         
When you ____, the file is located on the storage device and a variable name is associated with it.
Answer
read from a file
close a file
open a file
write to a file
Ans - open a file
2 points   
Question 6
1.         
In Java, methods must include all of the following except ___________.
Answer
curly braces
 declaration
a body
a call to another method
Ans - a call to another method
2 points   
Question 7
1.         
All method declarations contain ___________.
Answer
arguments
the keyword static
parentheses
one or more explicitly named access modifiers
Ans - parentheses
2 points   
Question 8
1.         
Which of the following method declarations is correct for a static method named displayFacts() if the method receives an int argument?
Answer
public static void displayFacts(int data)
public static int displayFacts()
public void displayFacts(int data)
Two of the presented answers are correct.
Ans - public static void displayFacts(int data)
2 points   
Question 9
1.         
Which of the following is a correct call to a method declared as public static void aMethod(char code)?
Answer
aMethod(char ‘M’);
aMethod(char ‘M’);
aMethod(‘Q’);
void aMethod(‘V’);
Ans - aMethod(‘Q’);
2 points   
Question 10
1.         
The method with the declaration public static int aMethod(double d) has a method type of ___________.
Answer
int
static
double
You cannot determine the method type.
Ans - int
2 points   



·         Q




No comments:

Post a Comment