13

Quiz 1

Today’s date:

Your name:

There are 65 questions. Unless otherwise noted, all questions are worth 1 point. The results will be adjusted to a 100-point scale overall. There are five choices for the multiple-choice questions. Check each page, front and back.

Circle the correct answer.

1. Which one of the following statements best describes the import keyword?

a.  Allow a modified reference to the import file in your current directory.

b.  Write a shorthand notation for the compiler to locate a built-in Java class file on the system.

c.  Save a file in the import directory.

d.  Prepare to delete all instances of an imported object.

e.  Import all files in the javax directory.

2. What is the purpose of javax.swing.JApplet at this point in the program?

  1. This is a reference to the Japplet class file, Japplet.class, located in the swing package on the system.
  2. This is a reference to the JApplet class file, JApplet.class, located in the swing package on the system.
  3. Copy JApplet class into the current directory.
  4. This is a reference to the JApplet class file, JApplet.class, located in the javax package on the system.
  5. This is a reference to the JApplet.java file located in the javax.file package on the system.

3. Which one of the following could be the last item that would complete import javax.swing.?

a.  JTextField:

b.  JTextField

c.  JTextField;

d.  jtextField;

e.  jTextField;

4. Which statement below is used to inform the compiler about the location of the JSlider.class file on the system?

a.  importjavax.swing.JSlider

b.  import javax.swing.JSlider.

c.  import javax.swing.jSlider;

d.  import javas.swing.JApplet;

e.  import javax.swing.JSlider;

5. Which one of the below is a correct path to a class file?

a. javax.swing:JTextArea

b. java.applet.applet

c. javax/swing/JLabel

d. java.Awt.label

e. java.net.URL

6. What is the purpose of the ; mark in a Java program?

  1. Designates a temporary separation when used in a package statement.
  2. It is used once and only once in a program.
  3. Designates the end of a statement or unit of Java code.
  4. It is used only with a JApplet class.
  5. It is an optional end-of-file marker.

7. Which statement below is used to inform the compiler about the location of the Color.class file on the system?

a. import java.awt.Color;

b. import java.swing.color.

c. import java.awt.Color.YELLOW;

d. import javas.swing.YELLOW;

e. import java.awt.color;

8. Which one of the below is a correct path to a class file?

a.  javax.swing:JTextArea

b.  java.applet.applet

c.  javax/swing/JLabel

d.  java.net.uRL

e.  javax.swing.JTextArea

9. Which one of the below is not a correct statement?

a. import java.awt.Color;

b. import javax.swing.JButton;

c. import javax.swing.JApplet;

d. import java.awt.color;

e. import javax.swing.JFrame;


10. What is the purpose of the public keyword?

a. It allows anyone on the Web to copy the file.

b. A class that is public is available to be used for the creation of an instance of the class.

c. It is a keyword for restricting access to the class or method it modifies.

d. It is interchangeable with the Public modifier.

e. It is known as a reference to the import keyword.

11. What is the purpose of the class keyword?

  1. The class keyword is the name of a Java variable.
  2. The class keyword is an object.
  3. Variables and methods are grouped together as a single named classs.
  4. Variables and methods are grouped together as a single named class.
  5. The class name invokes a method to classify the instance of an object.

12. Which of the following could be the name of a subclass of the JTextArea class?

a. MyJTextArea

b. JTextArea.subclass

c. myJTextArea

d. subclass.JTextArea

e. JTextArea(subclass)

13. What is the purpose of the extends keyword in …MyProgram extends JApplet…?

  1. The extends keyword indicates that this particular class, MyProgram, will be a subclass of the Applet class.
  2. The extends keyword indicates that this particular class, MyProgram, will be a subclass of the JApplet class.
  3. The extends keyword indicates that the MyProgram class will be a superclass of the JApplet class.
  4. The extends keyword indicates that this particular class, which is named MyProgram, will be a subclass of the applet class.
  5. The extends keyword indicates that this particular class, which is named MyProgram, will be a subclass of the jApplet class.

14. Which of the following best describes JApplet?

a. This is an object.

b. This is a class that is contained in the javax package.

c. This is an instance of the JLabel class.

d. This is a class that is contained in the swing package.

e. This is a method.

15. What is the purpose of { in the following: public class MyProgram extends JApplet {

a. It begins a group of lines of Java code in a method.

b. The { begins a groups of lines of Java code that are written in the myProgram class.

c. The { is used to close a method.

d. The { is an end-of-line marker.

e. The { is the opening brace for the code within the MyProgram class.

16. What is the purpose of JLabel in the following line: JLabel myLabel;

  1. JLabel is positioned to declare a string to be a potential instance of the JLabel class.
  2. The term JLabel indicates that this particular class will be a subclass of the MyLabel class.
  3. JLabel is positioned to declare a string to be a potential instance of the myLabel class.
  4. JLabel is a subclass of MyProgram.
  5. JLabel is a method.

17. What is the purpose of myLabel in the following line: JLabel myLabel;

a. The term myLabel used here in this program indicates that this class will be a subclass of the JLabel class.

b. It declares myLabel as a potential instance of the JLabel class.

c. The term myLabel used here in this program indicates that this class will be a subclass of the Jlabel class.

d. It declares myLabel as a potential instance of the JLabal class.

e. It declares mylabel as a potential instance of the JLabel class.

18. Which one of the below shows a correct use of the ; mark?

a.  myLabel JLabel;

b.  JLabel; myLabel

c.  myButton myLabel;

d.  JButton myButton;

e.  JButton MyProgram;

19. Which one of the below shows the correct use of public to modify a method?

a.  Public void init)

b.  public class MyProgram()

c.  void public init()

d.  public int myMethod()

e.  init() public void


20. Which statement is accurate for the use of void with a method?

  1. The void keyword means that the method will not return a value.
  2. The void keyword denotes a particular instance of the void class.
  3. The void method returns a void data type.
  4. The void keyword means that the statements in the method are not executed.
  5. This keyword voids the effects of a method.

21. Which statement below is correct?

  1. The init() method can also be written as Init().
  2. The ()init method used in MyProgram is an example of overriding a built-in method.
  3. The init() method used in MyProgram is an example of overriding a built-in method.
  4. The init)( method used in MyProgram is an example of overriding a built-in method.
  5. The init[] method used in MyProgram is an example of overriding a build-in method.

22. Which of the below shows the correct form of a method?

a. public int void goodBye() { code here }

b. public void MyProgram() { code here }

c. public voided hello() { code here }

d. public int GoodBye();

e. private int goodBye() {code here }

23. Which of the following is correct, given the line:

myLabel = new JLabel(“This is my first program.”);

  1. myLabel is being declared as an instance of the JLabel class.
  2. JLabel is being constructed as an instance of the Label class.
  3. myLabel is set to equal JLabel.
  4. myLabel is the name of a built-in Java class file named myLabel.class.
  5. myLabel is being constructed as an instance of the JLabel class.

24. What is the purpose of the = sign in the following line of code?

myLabel = new JLabel(“This is my first program.”);

a. This is the String comparison operator for JLabel objects.

b. It is used to construct an instance of the JLabel class.

c. It is an arithmetic operator used to give myLabel and integer value.

d. It tests the equivalence of JLabel objects.

e. It is used to construct an instance of the Jlabel class.


25. Which of the following is a correct statement regarding the new keyword in following line of code?

myLabel = new JLabel(“This is my first program.”);

a. It constructs a new instance of the myLabel class.

b. It updates the JLabel class.

c. It copies a new version of a JLabel .

d. It constructs a new instance of JLabel().java.

e. It is a Java keyword used to construct an instance of a class.

26. What is the purpose of JLabel(“This is my first program.”) in the following line of code?

myLabel = new JLabel(“This is my first program.”);

a. It declares a String variable to be an instance of the aName class.

b. It constructs a new instance of the MyLabel class.

c. It is a constructor method used to create a new instance of the JLabel class.

d. It passes a JLabel object to the constructor method.

e. It declares JLabel to be a String object.

27. Which of the below is the correct form for a constructor statement?

a.  myButton = new JButton(“Open”)

b.  MyFrame = new JFrame();

c.  myButton = new JButton”Close”;

d.  myFrame = new JFrame();

e.  new JButton = myButton();

28. Which of the below statements is correct?

a. setVisible(true).myLabel;

b. myLabel.GREEN;

c. getContentPane().setBackground(YELLOW);

d. getContentPane().setBackground(Color.BLUE);

e. MyLabel().setVisible(Color.YELLOW);

29. What is the purpose of the period (.) in the following statement?

getContentPane().setBackground(Color.YELLOW);

a. It terminates a Java sentence.

b. It terminates a Java statement.

c. It separates an object from a method that modifies a property of an object.

d. It separates an object from a method that modifies a property of the method.

e. It is a method terminator mark.


30. What is the purpose of the setBackground(Color.YELLOW) in the following statement?

getContentPane().setBackground(Color.YELLOW);

a. It has the effect of making MyLabel yellow.

b. It has the effect of making myLabel yellow;

c. It has the effect of making the content pane layer yellow.

d. It has the effect of making the JLabel object invisible to the user.

e. It has the effect of making the myLabel text yellow rather than black.

31. Which statement is written correctly?

a. getContentPane().setBackground(Color);

b. myLabel.setBackground(RED);

c. getContentPane.setBackground(Color.YELLOW);

d. getContentPane().setBackground(Color.BLUE);

e. myLabel.Color;

32. Which of the below retrieves the content pane layer of a JApplet container?

a.  GetContentPane()

b.  getContentPane

c.  getContentPane()

d.  RetrievePane()

e.  getPaneContent()

33. What is the correct classification of the period (.) in the Java programming language?

a. terminator

b. integrator

c. separator

d. classifier

e. indicator

34. Which of the following correctly adds an object to a container?

a.  JApplet.add(me);

b.  getContentPane.add(myLabel).

c.  myJPanel.add(myLabel);

d.  JPanel().add(myLabel);

e.  myLabel.addContentPane(this);


35. Which of the below shows an incorrect use of ; to complete a statement?

a. JPanel myPanel;

b. myJFrame = new JFrame();

c. Container contentpane = getContentPane();

d. setContentPane(myJPanel);

e. myStatement;()

36. A program has five methods in it. How many closing braces, }, are required to write only these methods in the program?

a. 8

b. 5

c. 3

d. 10

e. 12

37. Assume that a Java class that extends JScrollPane has three methods in it. How may total braces, { + }, are there in this program?

a. 5

b. 10

c. 6

d. 8

e. 12

38. Which of the following statements is correct?

a.  Import javax.swing.JApplet;

b.  import java.swing.JApplet;

c.  import javax.swing.JButton;

d.  import javaxswing.JApplet;

e.  import javax.swing.JApplet

39. Which of the following is a correct Java statement?

a.  import javax.swing.JLabel;

b.  import javax.swing.JLabel

c.  javax.swing.JLabel

d.  javax.swing.JLabel;

e.  import javax.swing.Jlabel;


40. Which of the following is a correct Java statement?

a.  import java.awt.Color;

b.  import javax.swing.JLabel

c.  javax.awt.Color;

d.  javax.swing.JLabel;

e.  import java.swing.Color;

41. Which of the following is a correct class definition?

a.  public class MyProgram extends JApplet }

b.  public StandardJFrame extends JApplet {

c.  public class MyLabel extends jlabel }

d.  class public MyJLabel extends JLabel {

e.  public class StandardJFrame extends JFrame {

42. Which one of the below is a correct declaration statement?

a.  JTextField myField

b.  JScrollPane myPane;

c.  JLabel() myLabel;

d.  JTextField myField();

e.  myLabel() JLabel;

43. Which of the below shows the correct form for a method?

a.  public void string start() { statements }

b.  public class init() { statements }

c.  public void Init() { statements }

d.  public void destroy() { statements }

e.  public init() destroy() [ statements ]

44. Which of the following is a correct constructor statement?

a.  myLabel = new JLabel(“This is my first program.”).

b.  myLabel = new JTextField(String);

c.  thisField new JLabel(“This is my first program.”);

d.  myLabel = new JLabel(“Hello”)

e.  thisField = new JTextField();

45. Which one of the below correctly applies a method to modify an object?

a.  myLabel().(false);

b.  myLabel.setForeground(Color.BLUE);

c.  setBackground(Color).true(RED);

d.  myPanel.setBackground(GREEN);

e.  getContentPane().set(myLabel.RED);

46. Which statement accurately adds an object to the content pane layer of a container?

a.  getContentPane().add(myJButton);

b.  getContentPane(myLabel);

c.  getContentPane.add(myLabel).

d.  myLabel.addcontent()Pane;

e.  myLabel.getContentPane();

47. Which of the following is the closing brace for a block of statements in a method?

a.  [

b.  {

c.  ]