Java Quiz
Java Quiz
Java Quiz
Question 1
Complete
Mark 1 out of 1
Send us a message
Select one:
a. Thread
b. None of the Mentioned
c. List
d. AbstractList
https://gtuconline.gtuc.edu.gh/online/mod/quiz/review.php?attempt=24233&cmid=6103&showall=1 1/34
10/05/2020 Mid Semester Exams 2020 Regular and Top-up
Question 2
Complete
Mark 1 out of 1
Select one:
a. False
b. True
Question 3
Complete
Send us a message
Mark 0 out of 1
https://gtuconline.gtuc.edu.gh/online/mod/quiz/review.php?attempt=24233&cmid=6103&showall=1 2/34
10/05/2020 Mid Semester Exams 2020 Regular and Top-up
Question 4
Complete
Mark 1 out of 1
Send us a message
Question 5
Complete
Mark 1 out of 1
Which of the following statements are true?
https://gtuconline.gtuc.edu.gh/online/mod/quiz/review.php?attempt=24233&cmid=6103&showall=1 3/34
10/05/2020 Mid Semester Exams 2020 Regular and Top-up
Question 6
Complete
Mark 1 out of 1
Which method overrides the default behavior for the JFrame to be positioned in the upper-left corner of the computer screen’s desktop?
Select one:
a. title()
b. setBounds()
c. isResizable()
d. setSize()
Send us a message
https://gtuconline.gtuc.edu.gh/online/mod/quiz/review.php?attempt=24233&cmid=6103&showall=1 4/34
10/05/2020 Mid Semester Exams 2020 Regular and Top-up
Question 7
Complete
Mark 1 out of 1
The GeometricObject and Circle classes are de ned in this chapter. Analyze the following code.
Send us a message
d. If GeometricObject implements Cloneable and Circle overrides the clone() method, the clone() method will work ne to clone Circle
objects.
https://gtuconline.gtuc.edu.gh/online/mod/quiz/review.php?attempt=24233&cmid=6103&showall=1 5/34
10/05/2020 Mid Semester Exams 2020 Regular and Top-up
Question 8
Complete
Mark 1 out of 1
Suppose A is an interface, B is a concrete class with a default constructor that implements A. Which of the following is correct?
Send us a message
Question 9
Complete
Mark 1 out of 1
You can use the keyword _______ within a method in a derived class to access an overridden method in a base class.
Select one:
a. this
b. sub
c. protected
d. super
https://gtuconline.gtuc.edu.gh/online/mod/quiz/review.php?attempt=24233&cmid=6103&showall=1 6/34
10/05/2020 Mid Semester Exams 2020 Regular and Top-up
Question 10
Complete
Mark 1 out of 1
Send us a message
}
class Output
{
public static void main(String args[])
{
B obj = new B();
obj.i=1;
obj.j=2;
obj.display();
}
}
Select one:
a. 1 2
b. 3 1
c. 1 3
d. 2 1
https://gtuconline.gtuc.edu.gh/online/mod/quiz/review.php?attempt=24233&cmid=6103&showall=1 7/34
10/05/2020 Mid Semester Exams 2020 Regular and Top-up
Question 11
Complete
Mark 0 out of 1
Instead of using the automatic toString() method with your classes, it is usually more useful to write your own ____ version of the toString()
method that displays some or all of the data eld values for the object with which you use it.
Select one:
a. overridden
b. static
c. protected
d. overloaded
Send us a message
Question 12
Complete
Mark 1 out of 1
An interface cannot extend more than one interface.
Select one:
a. true
b. false
https://gtuconline.gtuc.edu.gh/online/mod/quiz/review.php?attempt=24233&cmid=6103&showall=1 8/34
10/05/2020 Mid Semester Exams 2020 Regular and Top-up
Question 13
Complete
Mark 1 out of 1
If you provide an empty method within an abstract class, the method is an abstract method even if you do not explicitly use the keyword
abstract when de ning the method.
Question 14
Complete
Mark 1 out of 1
Send us a message
You use the keyword ________ to reference a method in the superclass from a subclass.
Select one:
a. super
b. superObject
c. that
d. this
https://gtuconline.gtuc.edu.gh/online/mod/quiz/review.php?attempt=24233&cmid=6103&showall=1 9/34
10/05/2020 Mid Semester Exams 2020 Regular and Top-up
Question 15
Complete
Mark 1 out of 1
Select one:
a. Private methods
b. Protected methods
c. Multithreading
d. Interfaces
Send us a message
Question 16
Complete
Mark 1 out of 1
The UML uses ________ before a member name to indicate that the member is protected.
Select one:
a. +
b. ?
c. #
d. -
https://gtuconline.gtuc.edu.gh/online/mod/quiz/review.php?attempt=24233&cmid=6103&showall=1 10/34
10/05/2020 Mid Semester Exams 2020 Regular and Top-up
Question 17
Complete
Mark 1 out of 1
Which of these class relies upon its subclasses for complete implementation of its methods?
Select one:
a. Object class
b. abstract class
c. None of the mentioned
d. ArrayList class
Send us a message
Question 18
Complete
Mark 1 out of 1
Must a program respond to all events that its components generate?
Select one:
a. Yes---the program that is running must handle all events that happen in anywhere one the screen or mouse.
b. No---the operating system sends the program only those events it can handle.
c. No---it can safely ignore events that don't concern it.
d. Yes---if an event is generated that it can't handle it will bomb.
https://gtuconline.gtuc.edu.gh/online/mod/quiz/review.php?attempt=24233&cmid=6103&showall=1 11/34
10/05/2020 Mid Semester Exams 2020 Regular and Top-up
Question 19
Complete
Mark 1 out of 1
You cannot create an instance of an abstract class using the new operator.
Select one:
a. true
b. false
Question 20
Complete
Send us a message
Mark 1 out of 1
https://gtuconline.gtuc.edu.gh/online/mod/quiz/review.php?attempt=24233&cmid=6103&showall=1 12/34
10/05/2020 Mid Semester Exams 2020 Regular and Top-up
Question 21
Complete
Mark 1 out of 1
Select one:
a. p.setEast(node);
b. p.placeLeft(node);
c. p.setLeft(node);
d. p.left(node);
Send us a message
Question 22
Complete
Mark 1 out of 1
Which of these is supported by method overriding in Java?
Select one:
a. Abstraction
b. Encapsulation
c. Polymorphism
d. None of the mentioned
https://gtuconline.gtuc.edu.gh/online/mod/quiz/review.php?attempt=24233&cmid=6103&showall=1 13/34
10/05/2020 Mid Semester Exams 2020 Regular and Top-up
Question 23
Complete
Mark 1 out of 1
Select one:
a. Only once when the frame is created.
b. Always---whenever any method nishes.
c. Never--that is the system's job.
d. Whenever it has made a change to what should be displayed in the Frame.
Send us a message
Question 24
Complete
Mark 1 out of 1
Which of the following statements correctly creates a Color object?
https://gtuconline.gtuc.edu.gh/online/mod/quiz/review.php?attempt=24233&cmid=6103&showall=1 14/34
10/05/2020 Mid Semester Exams 2020 Regular and Top-up
Question 25
Complete
Mark 0 out of 1
Assume Calendar calendar = new GregorianCalendar(). ________ returns the month of the year.
Select one:
a. calendar.get(Calendar.MONTH_OF_YEAR)
b. calendar.get(Calendar.WEEK_OF_YEAR)
c. calendar.get(Calendar.MONTH)
d. calendar.get(Calendar.WEEK_OF_MONTH)
Send us a message
Question 26
Complete
Mark 1 out of 1
Which of the following statements will set the background color of a button named stop to a color of red?
Select one:
a. setBack.stop.Color.RED;
b. stop.Backcolor = RED;
c. stop.setBackground(Color.RED);
d. red.setBackground(Color.RED);
https://gtuconline.gtuc.edu.gh/online/mod/quiz/review.php?attempt=24233&cmid=6103&showall=1 15/34
10/05/2020 Mid Semester Exams 2020 Regular and Top-up
Question 27
Complete
Mark 1 out of 1
If super class and sub class have same variable name, which keyword should be used to use super class?
Select one:
a. this
b. super
c. classname
d. upper
Send us a message
Question 28
Complete
Mark 1 out of 1
An abstract class can be extended.
Select one:
a. true
b. false
https://gtuconline.gtuc.edu.gh/online/mod/quiz/review.php?attempt=24233&cmid=6103&showall=1 16/34
10/05/2020 Mid Semester Exams 2020 Regular and Top-up
Question 29
Complete
Mark 1 out of 1
Select one:
a. dynamic method binding
b. method xing
c. implicit casting
d. implementing methods
Send us a message
Question 30
Complete
Mark 1 out of 1
If a user enters more characters than speci ed in a JTextField, the extra characters are deleted.
Select one:
a. False
b. True
https://gtuconline.gtuc.edu.gh/online/mod/quiz/review.php?attempt=24233&cmid=6103&showall=1 17/34
10/05/2020 Mid Semester Exams 2020 Regular and Top-up
Question 31
Complete
Mark 1 out of 1
When you create a class and use the implements clause to implement an interface but fail to code one of the interface’s methods, the
compiler error generated indicates that you must declare your class to be ____.
Select one:
a. public
b. static
c. related
d. abstract
Send us a message
Question 32
Complete
Mark 1 out of 1
To add two nodes node1 and node2 to the the rst row in a GridPane pane, use ________.
https://gtuconline.gtuc.edu.gh/online/mod/quiz/review.php?attempt=24233&cmid=6103&showall=1 18/34
10/05/2020 Mid Semester Exams 2020 Regular and Top-up
Question 33
Complete
Mark 1 out of 1
It is useful to override the parent class members when the superclass data elds and methods are not completely appropriate for the
subclass objects.
Select one:
a. False
b. True
Question 34
Send us a message
Complete
Mark 1 out of 1
How many GUI components can go into each cell with GridPane?
Select one:
a. 1
b. Only one Panel per cell.
c. As many as you need.
d. None
https://gtuconline.gtuc.edu.gh/online/mod/quiz/review.php?attempt=24233&cmid=6103&showall=1 19/34
10/05/2020 Mid Semester Exams 2020 Regular and Top-up
Question 35
Complete
Mark 0 out of 1
Programmers and analysts sometimes use a graphical language to describe classes and object-oriented processes. This language is called
Uni ed Modelling Language .
Question 36
Complete
Mark 1 out of 1
Send us a message
Using the keyword ____ provides you with an intermediate level of security between public and private access.
Select one:
a. secure
b. super
c. this
d. protected
https://gtuconline.gtuc.edu.gh/online/mod/quiz/review.php?attempt=24233&cmid=6103&showall=1 20/34
10/05/2020 Mid Semester Exams 2020 Regular and Top-up
Question 37
Complete
Mark 1 out of 1
If a parameter is of the java.lang.Object type, you can pass any object to it. This is known as generic programming.
Select one:
a. false
b. true
Question 38
Complete
Send us a message
Mark 0 out of 1
https://gtuconline.gtuc.edu.gh/online/mod/quiz/review.php?attempt=24233&cmid=6103&showall=1 21/34
10/05/2020 Mid Semester Exams 2020 Regular and Top-up
Question 39
Complete
Mark 1 out of 1
. Usually, the subclass constructor only needs to initialize the ____ that are speci c to the subclass.
Select one:
a. methods
b. objects
c. data elds
d. constructors
Send us a message
Question 40
Complete
Mark 1 out of 1
To construct a Polygon with three points x1, y1, x2, y2, x3, and y3, use ________.
https://gtuconline.gtuc.edu.gh/online/mod/quiz/review.php?attempt=24233&cmid=6103&showall=1 22/34
10/05/2020 Mid Semester Exams 2020 Regular and Top-up
Question 41
Complete
Mark 1 out of 1
When you create a class and do not provide a(n) ____, Java automatically supplies you with a default one.
Select one:
a. argument
b. header
c. name
d. constructor
Send us a message
Question 42
Complete
Mark 1 out of 1
Which of the following statements are true?
Select one:
a. A Node can be placed in a Pane.
b. A Pane can be placed in a Control.
c. A Node can be placed in a Scene.
d. A Shape can be placed in a Control.
https://gtuconline.gtuc.edu.gh/online/mod/quiz/review.php?attempt=24233&cmid=6103&showall=1 23/34
10/05/2020 Mid Semester Exams 2020 Regular and Top-up
Question 43
Complete
Mark 1 out of 1
which method declaration overload method m1?
Select one:
a.
public void m1(int num1, double num2){}
Send us a message
b.
public string m1(int num1, int num2, int num3){}
c.
public int m1(int num1, int num2){}
d.
public void m2(int num1, int num2){}
https://gtuconline.gtuc.edu.gh/online/mod/quiz/review.php?attempt=24233&cmid=6103&showall=1 24/34
10/05/2020 Mid Semester Exams 2020 Regular and Top-up
Question 44
Complete
Mark 1 out of 1
Assume an employee can work for only one company. What is the best suitable relationship between Company and Employee?
Select one:
a. Inheritance
b. None
c. Composition
d. Aggregation
Send us a message
Question 45
Complete
Mark 0 out of 1
Match each term with the correct statement below.
Can be used with the setBackground() and setForeground() methods of the Component class Color class
Use when you need to add components into rows and columns; each component is the same size BorderLayout
https://gtuconline.gtuc.edu.gh/online/mod/quiz/review.php?attempt=24233&cmid=6103&showall=1 25/34
10/05/2020 Mid Semester Exams 2020 Regular and Top-up
Question 46
Complete
Mark 1 out of 1
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Pane;
import javafx.geometry.Insets;
import javafx.stage.Stage;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
Send us a message
Select one:
a. new Image("www.cs.armstrong.edu/liang/image/us.gif") must be replaced by new
Image("http://www.cs.armstrong.edu/liang/image/us.gif").
b. The addAll method needs to be replaced by the add method.
c. The image object cannot be shared by two ImageViews.
d. The program runs ne and displays two images.
https://gtuconline.gtuc.edu.gh/online/mod/quiz/review.php?attempt=24233&cmid=6103&showall=1 26/34
10/05/2020 Mid Semester Exams 2020 Regular and Top-up
Question 47
Complete
Mark 1 out of 1
Select one:
a. Animal[] animalRef = new Animal[3];
b. Animal[] new = ref Animal[3];
c. Animal[] ref = extend Animal[3];
d. Animal[] ref = new Animal(3);
Send us a message
Question 48
Complete
Mark 1 out of 1
public B(Strign s) {
Select one:
a. The program would compile ne if you add the following constructor into A: A(String s) { super(s); }
b. The program has a compilation error because A does not have a default constructor.
c. The program would compile ne if you add the following constructor into A: A(String s) { }
d. The program has a compilation error because the default constructor of A invokes the default constructor of B, but B does not have
a default constructor.
https://gtuconline.gtuc.edu.gh/online/mod/quiz/review.php?attempt=24233&cmid=6103&showall=1 27/34
10/05/2020 Mid Semester Exams 2020 Regular and Top-up
Question 49
Complete
Mark 1 out of 1
Select one:
a. A public class can be accessed by a class from a di erent package.
b. A method with no visibility modi er can be accessed by a class in a di erent package.
c. A private method cannot be accessed by a class in a di erent package.
d. A protected method can be accessed by a subclass in a di erent package.
Send us a message
Question 50
Complete
Mark 0 out of 1
The UML uses ________ before a member name to indicate that the member is package-private.
Select one:
a. -
b. #
c. +
d. none (blank)
https://gtuconline.gtuc.edu.gh/online/mod/quiz/review.php?attempt=24233&cmid=6103&showall=1 28/34
10/05/2020 Mid Semester Exams 2020 Regular and Top-up
Question 51
Complete
Mark 1 out of 1
Select one:
a. class B inherits class A {}
b. class B extends A {}
c. class B extends class A {}
d. class B + class A {}
Send us a message
Question 52
Complete
Mark 1 out of 1
All classes in Java are inherited from which class?
Select one:
a. java.class.object
b. java.lang.Object
c. java.lang.class
d. java.class.inherited
https://gtuconline.gtuc.edu.gh/online/mod/quiz/review.php?attempt=24233&cmid=6103&showall=1 29/34
10/05/2020 Mid Semester Exams 2020 Regular and Top-up
Question 53
Complete
Mark 1 out of 1
Select one:
a. Inheritance
b. None
c. Aggregation
d. Composition
Send us a message
Question 54
Complete
Mark 1 out of 1
Every class has a toString() method and an equals() method.
Select one:
a. false
b. true
https://gtuconline.gtuc.edu.gh/online/mod/quiz/review.php?attempt=24233&cmid=6103&showall=1 30/34
10/05/2020 Mid Semester Exams 2020 Regular and Top-up
Question 55
Complete
Mark 1 out of 1
Send us a message
Question 56
Complete
Mark 0 out of 1
When a user closes a JFrame by clicking the Close button in the upper-right corner, the default behavior is for the JFrame to close and the
application to terminate.
Select one:
a. True
b. False
https://gtuconline.gtuc.edu.gh/online/mod/quiz/review.php?attempt=24233&cmid=6103&showall=1 31/34
10/05/2020 Mid Semester Exams 2020 Regular and Top-up
Question 57
Complete
Mark 1 out of 1
An interface can extend any number of interfaces using the extends keyword.
Select one:
a. true
b. false
Question 58
Complete
Send us a message
Mark 0 out of 1
Select one:
a. true
b. false
https://gtuconline.gtuc.edu.gh/online/mod/quiz/review.php?attempt=24233&cmid=6103&showall=1 32/34
10/05/2020 Mid Semester Exams 2020 Regular and Top-up
Question 59
Complete
Mark 1 out of 1
What is it called when a program is written to respond to the button clicks, menu selections, and other actions of the user in whatever order
the user does them?
Select one:
a. Event-driven programming.
b. Mouse-driven programming
c. User-driven programming.
d. Action-driven programming.
Send us a message
Question 60
Complete
Mark 0 out of 1
. As you add new Components to a ____, they are positioned in sequence from left to right across each row.
Select one:
a. HBox
b. CardPane
c. GridPane
d. BorderPane
https://gtuconline.gtuc.edu.gh/online/mod/quiz/review.php?attempt=24233&cmid=6103&showall=1 33/34
10/05/2020 Mid Semester Exams 2020 Regular and Top-up
https://gtuconline.gtuc.edu.gh/online/mod/quiz/review.php?attempt=24233&cmid=6103&showall=1 34/34