QuestionQuestion

Which of the following file names is valid for a source file containing the definition of
a public class called Customer?
Customer.src
Customer.java
customer. java
Customer. class

Question 2
Which of the following element orders are correct in a Java source file?
I. import statements, package declaration, class definition
II. import statements, class definition
III. package declaration, class definition
IV. package declaration, import statements, class definition

III only
IV only
I only
I, II & III
II, III & IV

What is the correct range of values for the primitive type int?
-2³¹ to 2³¹ - 1
-2³¹ to 2³¹
0 to 2³²
-2¹⁵ to 2¹⁵
0 to 2¹⁵

Which of the following main() method signatures are valid entry points for Java
applications?
I. static public void main(String largs[])
II. static public void main(String[] largs)
III. public static void main(String largs[])
IV. public static void main(String[] largs)

I,IV
III
1,11
All of the above

When a method of a public class is declared protected, it is accessible from:
I. any class
II. any class in the same package
III. any subclass in the same package
O I
Il
III
Il and III
All of the above

Which of the following classes is part of the java.lang package?
A) String
B) Integer
C) Long
D) A and B
E) All of the above

Question 7
Which of the statements below will cause a compiling error?
Object test = null; (This statement applies to I, II, III, and IV)
I. if (test I= null)
II. if (test.equals("test"))
III. if ((test = "test") == null)
IV. if (test)
O I
II
III
IV
All of the above

Question 8
Which of the following will the output be for the code fragment below?
String str = "red";
changeString(str);
System.out.printIn(str);
public void changeString(String : s) {s = "brown";}
red
brown
redbrown
browned

Question 9
Which of the following will be the output for the code fragment below?
String str = "blue";
if (str.equals("blue"))
System.out.println("one");
if (str == new String("blue"))
System.out.println("two");
one
two
one then two
blank space

Question 10
When a method in a class is declared abstract, the class must be declared which of
the following?
A) public
B) protected
C) abstract
D) B and C
E) A and C

Question 11
If you override a method that throws an 10Exception, which of the following
statements is valid?
I. The method throws an IOException.
II. The method throws a MalformedURLException (subclass of IOException).
III. The method throws a TooManyListenersException (not a subclass of
IOException).
O
I
II
III
I and Il
All of the above

Question 12
Which of the identifiers below (variable, method, class or label) is valid?
I. cost
II. extends
III. Stotal
IV. 2bad
I and II
I, II, and III
I and III
I and IV

Question 13
Which of the following indicates the default layout manager for a Panel?
BorderLayout
GridLayout
GridBagLayout
FlowLayout

Question 14
Which of the following indicates the default layout manager for a Frame?
BorderLayout
GridLayout
GridBagLayout
FlowLayout

Question 15
You can call one constructor from another if a class has multiple constructors.
True
False

Question 16
You CANNOT write a Java class that could be used as an applet as well as an
application.
True
False

Question 17
Which of the following is the correct way to determine the size of an array of
animals?
animals.length
animals.size
animals.length()
animals.size()

Question 18
Which of the following examples of String method would return "test" from the String
"This is a test"?
substring(11, 15)
substring(10, 14)
subString(11, 15)
subString(10, 14)

Question 19
Which of the following is NOT a valid expression in a switch statement?
I. Integer
II. char
III. int
IV. Object
V. Character
IV
Il and III
II, III, and IV
I, IV, and V

Question 20
Runtime Exceptions must be caught in a try/catch block.
True
False

Question 21
Which of the following methods is an invalid overload or override of the code below?
public void
calculate(int a)
public void calculate(String s)
public int calculate(int i)
public void calculate(int i, int a)
public void calculate(double d)

Question 22
Which of the following statements about the File class objects is FALSE?
It can test to see if the File object refers to an existing file.
It can delete the file that the File object refers to.
It can determine if a file can be read or written to.
It can automatically create a new, empty file named by an abstract pathname even if a file with this name already exists.

Question 23
An object named btnHandler implements the ActionListener interface. Which of the
following will register btnHandler to receive ActionEvents from a Button object
named btn?
btn.register(btnHandler)
otn.add(btnHandler)
btn.addActionListener(btnHandler)
btnHandler.addActionListener(btn)

Question 24
The Serializable interface declares which of the following methods?
I. private void writeObject(java.io.ObjectOutputStreamout) throws IOException
II. private void adObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException
III. private void writeObject(java.io.ObjectOutputStreamout) IV. private void
dObject(java.io.ObjectInputStream in)
OI
Il
III
III and IV
All of the above

Question 25
Which of the following keywords should you use for an instance variable so that the
value would NOT be serialized?
abstract
const
native
private
transient

Question 26
The java compiler automatically imports all of the classes from the package
java.lang into every source file.
True
False

Question 27
Given the code below, in which of the following locations does the button get placed?
Panel panel = new Panel();
panel.setLayout(new BorderLayout());
panel. add(new Button("Whe Am I"));
The button is placed in the North location
The button is placed in the South location.
The button is placed in the Center location.
The button is placed in the West location.
The button is placed in the East location

Question 28
Which of the following statements about try/catch blocks is TRUE?
Code may be placed between the end of the try block and the beginning of the catch block.
The code in the try/catch block is executed regardless of whether the exception handler is executed
Try/catch block exception handlers can only stop a program or print error messages.
When a try/catch block of code is used to catch multiple exceptions, it should be ordered from specific to general.

Question 29
For the unsigned right-shift operator >>> the new bits take the value of the most significant bit before the shift.
True
False

Question 30
Which of the following statements indicates the result of the code fragment below?
int flavors = 23;
String message = "There are " + flavors + available flavors."
System.out.printIn(message);
"23 There are available flavors.'
"There are 23 available flavors."
"There are available flavors."
It will throw a runtime exception when trying to create the message String.

Question 31
Which of the following is an invalid way of declaring an Integer object?
I. Integer idx = new Integer();
II. Integer idx = new Integer("1")
III. Integer idx = new Integer(10) idx = 10;
IV. Integer idx = new Integer(10); idx setIntValue(12);
V. Integer idx = new Integer("23") double didx = idx.doubleValue();
O I
III
Il and IV
I, III, and IV

Question 32
Which of the following keywords is used to make a method or variable belong to the
Class rather than an instance of the class?
public
static
final
synchronized
volatile

Question 33
Which of the following keywords guarantees that only one thread at a time will execute an object's method or a piece code?
transient
final
synchronized
volatile
static

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

Customer.java

II, III and IV

1st

All of the Above

II and III (4th one)...
$25.00
for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Java Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats