IAPP001 Multiple Choice

A vibrant illustration depicting Java programming concepts, including OOP, design patterns, and a quiz format with thought bubbles and code snippets in the background.

Mastering Java Concepts: A Comprehensive Quiz

Test your knowledge of Java programming concepts with this engaging quiz designed for enthusiasts and professionals alike. Covering topics such as OOP principles, design patterns, and method overloading, this quiz will challenge your understanding and reinforce your learning.

  • 78 thought-provoking questions
  • Multiple choice, text, and checkbox formats
  • Assess your skills and knowledge
78 Questions20 MinutesCreated by CodingExpert123
The term used to describe two or more methods in the same class or package that have the same name
Overloading
Oversuding
MyObserver
Constructor
What is dynamic dispatch?
Dynamic dispatch is where the actual type of the object determines which implementation of a method is called.
Dynamic Dispatch is where the dynamic type is determined by a dispatch
Dynamic Dispatch is where the called method changes the type of the object
I dont know - is it a vibrant method exit?
What is the point of MVC?
To separate the GUI and the view
To separate the view and the model
To separate the controller and the model
To separate the controller and the view
In the observer pattern, what class must a panel inherit from?
Overloading
MyObserver
Constructor
Iteration
What is the difference between a function and a procedure
Nothing, they are interchangeable words.
A function returns a value. A procedure returns nothing ie it has a return type of void.
A procedure returns a value. A function returns nothing ie it has a return type of void.
I don't know - aren't they both types of methods.
What does a constructor do?
It constructs a class
I dont know - it might be there for decoration.
It creates an object of the class' datatype. When the object is created, it has the attributes and methods declared in the class.
It assigns data values to the attributes in the class
Consider the following code:
Animal animal;
animal.getName();
 
What is wrong this this code?
Nothing
It will compile but it will cause an index out of bounds exception
It will not compile
It will compile but will cause a null pointer exception
How do you call the default constructor of a parent class?
How do you iterate though a LinkedList?
For (Object object : objects)
For(Object object ; objects)
For (i = 0; i
While(itr.hasNext())
What is the keyword used in Interface Inheritance?

Using the following code:

1                    public      abstract class ClassA

2                    {

3                        protected int variable1;

4                        public ClassA(int a)

5                        {

6                            variable1 = a;

7                        }

8                        public abstract void method1();

9                        public String method2()

10                     {

11                         return "Something";

12                     }

13                 }   

                      

1                    public      class ClassB extends ClassA

2                    {

3                        public ClassB(int number)

4                        {

5                            super(number);

6                        }

7                        public void method1()

8                        {

9                           ++variable1;

10                     }

11                     public int method1(int y)

12                     {

13                         return (int)Math.pow(y, 3);

14                     }

15                      public String method2()

16                     {

17                         return "Something else";

18                     }

19                 }

       

What type of inheritance is used?

What does a list iterator do?
Adds an element to a list
Retrieves an element from a list
Removes an element from a list
All of the above
The term used to describe two or more methods in the same class or package that have the same name.
In polymorphism, the runtime uses the ____ type of the object to determine which method is called.
An abstract class can have implemented methods
True
False
How can I make a panel an observer of a model?
The panel must inherit from MyObserver
The model must have an attach() method
Call model.attach(this); from the panel constructor
All of the above
In the observer pattern, what class must a panel inherit from?
What is encapsulation?
A. I don't know - is it a type of hat?
B. It's where attribute values and methods are stored together
C. It's a type of attribute
D. It's a type of method
How can I make a panel an observer of a model?
The panel must inherit from MyObserver
The model must have an attach() method
Call model.attach(this); from the panel constructor
All of the above
Given the following method signatures:
setLength(double length)
setLength(String length)
 
This is an example of overloading.
True
False
Extends is a type of inheritance in Java
True
False
What visibility modifier (private, public or protected) should be used for an attribute in a normal class (no inheritance)?
Public
Private
Protected
Any modifier is fine
What are the 3 kinds of reuse?
Method, object and class
I don't know - does it really matter?
Method, constant and class
Attribute, method and object

Using the following code:

  1. public      abstract class ClassA
  2. {
  3.     protected int variable1;
  4.     public ClassA(int a)
  5.     {
  6.         variable1 = a;
  7.     }
  8.     public abstract void method1();
  9.     public String method2()
  10.     {
  11.         return "Something";
  12.     }
  13. }   

 

  1. public      class ClassB extends ClassA
  2. {
  3.     public ClassB(int number)
  4.     {
  5.         super(number);
  6.     }
  7.     public void method1()
  8.     {
  9.        ++variable1;
  10.     }
  11.     public int method1(int y)
  12.     {
  13.         return (int)Math.pow(y, 3);
  14.     }
  15.      public String method2()
  16.     {
  17.         return "Something else";
  18.     }
  19. }

 What type of inheritance is used?

What visibility modifier should an inner class have?
Write the code to add a JLabel called name to a panel called userPanel
What is dynamic dispatch?
Dynamic dispatch is where the actual type of the object determines which implementation of a method is called.
Dynamic Dispatch is where the dynamic type is determined by a dispatch
Dynamic Dispatch is where the called method changes the type of the object
I don't know - is it a vibrant method exist?

Given the following method signatures:

setLength(double length)

setLength(String length)

This is an example of overloading
True
False
What are the 3 kinds of reuse?
I don't know - does it really matter?
Attribute, method and object
Method, constant and class
Method, object and class
What is the difference between a function and a procedure
Nothing, they are interchangeable words
A function returns a value. A procedure returns nothing ie it has a return type of void.
A procedure returns a value. A function returns nothing ie it has a return type of void.
I dont know - aren't they both types of methods.
What is overriding?
I dont know - is it where a method is executed too quickly?
Overriding is where a child class provides an alternative implementation for a method defined in the parent class. The method signatures must be the same.
Overriding is where a child class provides an alternative implementation for a method defined in the parent class. The method signatures do not have to be the same.
Overriding is where a class has multiple methods with the same name but different parameters.
An abstract class can have implemented methods
True
False

Given the following method signatures:

setLength(double length)

setLength(String length)

 

This is an example of overloading

True
False
Extends is a type of inheritance in Java
True
False
How do you call the default constructor of a parent class?
What is encapsulation?
Its where attribute values and methods are stored together
It's a type of attribute
I don't know - is it a type of hat ?
It's a type of method
Write the code to add a JLabel called name to a panel called userPanel

In the following code example, which is the only polymorphic line of code?

public class Shapes
{
    private LinkedList<Shape> shapes = new LinkedList<Shape>();

    public Shapes()
    {        
           shapes.add(new Rectangle(5, 2));
           shapes.add(new Circle(2));
           shapes.add(new Triangle(3, 4, 5, 3));
    }
    public void listProperties()
    {
        for (Shape shape : shapes) {
            System.out.println("Area is:" + current.area());
        }
    }
}

For (Shape shape : shapes)
System.out.println("Area is:" + current.area());
Private LinkedList shapes = new LinkedList();
Public class Shapes

Consider the following code:

            Animal animal;

            animal.getName();

What is wrong this this code?
Nothing
It will compile but it will cause an index out of bounds exception
It will compile but will cause a null pointer exception
It will not compile
What does Java compare to find the right method header to match a method call?
Method name
Method name and number of parameters
Method name, number and types of parameters
Method name, number, type, and order of parameters
Method name, number, type, order, and name of parameters
Which of the following statements is true about functions?
A function has side effects and can call a procedure.
A function has no side effects and can call a procedure.
A function has side effects and cannot call a procedure.
A function has no side effects and cannot call a procedure.
A function can have many parameters, but must have a return type of void.
What String function returns a sub-string of a string?
ToSubString
ToSubstring
SubString
Substr
Substring
The following question refers to this pattern:
if () return false;
return true;
The following question refers to this pattern:
if () return false;
return true;
What is the name of this pattern?
For-each loop
Lookup
None
Every
Any
When do you need braces around a chunk of code?
When there is more than one statement
When the code goes over several lines
When the code is complex
After an if
After an if or for
The following question refers to the method shown below.
private Worker worker(int id) { for (Worker worker : workers) if (worker.matches(id))
return worker;
;
}
The following question refers to the method shown below.
private Worker worker(int id) { for (Worker worker : workers) if (worker.matches(id))
return worker;
;
}
What line replaces ?
Break
Return
Return new Worker()
Return null
Return "Not found"
The following question refers to this code:
private boolean any() {
for (Element e : elements)
if () return ; return ;
}
The following question refers to this code:
private boolean any() {
for (Element e : elements)
if () return ; return ;
}
What line replaces ​<xxx2xxx>?
E
Element
Null
True
False
In terms of duration, which phase of software engineering is most affected by applying object-oriented design principles?
Analyse
Design
Code
Debug
Extend
Which is not a benefit of object-oriented programming?
Objects hide implementation details
Dependencies are easier to manage
Objects better map onto the way the real world works
Classes are encapsulated inside of objects
Classes help to separate concerns.
Which of the following best describes polymorphism
A variable can have multiple types.
An object can have multiple types.
A class can extend multiple superclasses.
A class can implement multiple interfaces.
Polymorphism literally means “many objects”.
Which interface does an observer implement to respond to button clicks?
ActionEvent
SelectionEvent
ActionListener
ChangeListener
EventHandler
The following question refers to the following line of code:
Customer customer = new Customer();
customer.addAccount(scanner.nextLine());
The following question refers to the following line of code:
Customer customer = new Customer();
customer.addAccount(scanner.nextLine());
If a NullPointerException is thrown, which code is most likely to be null?
Customer
New Customer()
AddAccount
Scanner
NextLine
Which best defines the throws keyword in Java?
It defines an exception.
It throws an exception.
It indicates that an exception might be thrown.
It sets the exception message.
This keyword does not exist in Java.
Which of the following lines of code defines a new JavaFX application class?
Class MyApplication extends Application
Class MyApplication inherits Application
Class MyApplication implements Application
Class MyApplication throws Application
Class MyApplication uses Application
Which of the following is a valid use of the @Overrides annotation?
On an abstract method.
To link a controller to an FXML file.
On an interface method.
On a method that must be overridden.
On an implementation of an interface method.
What code registers a listener l for when the selection of a toggle group g changes?
G.getToggleGroup().selectedItemProperty().addListener(l);
G.selectedToggleProperty().addListener(l);
G.getSelectionModel().getSelectedItem().addListener(l); d)
G.getSelectionModel().selectedItemProperty().addListener(l);
G.selectionModel().addListener(l);
Which of the following is true about ArrayList?
Inserting an item at the beginning of an ArrayList is fast.
Modifying an item in the middle of an ArrayList is fast.
ArrayList is like LinkedList except that an ArrayList has a fixed size.
Adding an item to the end of an ArrayList is normally very slow.
All of the above.
How many pointers need to be set to delete an element from a linked list?
O
1
2
3
4
How does a TableView tv get linked to an observable list l?
Tv.setList(l)
L.addListener(tv)
Tv.addModel(model)
Tv.addTable(table)
L.attach(tv)
Which is not a supported way to define an observer for a button click in Java 7?
As an inner class.
As an anonymous inner class.
As a lambda expression
As a method annotated with @FXML
As a top level class.
What API class does enum inherit from
Enum
Enum
Entity
Object
The default parent class for all classes in Java is
Object
Parent
String
Record
What is the keyword used in Implementation Inheritance?
This
Extends
Implements
Super
What is the keyword used in Interface Inheritance?
This
Extends
Implements
Super
An abstract class uses Interface Inheritance
True
False
How do you retrieve the 3rd element in LinkedList?
List.get(3);
List.get(2);
List.retrieve(3);
List.retrieve(2);
What is a static type?
The type of a static attribute.
The declared type.
The type of the object actually pointed to by the variable.
A type that cannot change.
What is dynamic dispatch?
Objects can react differently when the same method is called on them
The allocated type determines which method is called
The passing on of characteristics or attributes from one entity to another
The encapsulation of data
What is the basic principle in the MVC pattern?
To separate the GUI and domain classes.
To separate the view and domain classes.
To encapsulate the GUIs in a separate package.
To allow changes to the GUI with no effect on the model.
A class can implement multiple interfaces:
True
False
An abstract class:
Always has abstract methods
Cannot be subclassed
Can have implemented methods
Must have constant variables
What kind of event is generated by a list choice?
ActionEvent
SelectionEvent
ChoiceEvent
ListSelectionEvent
Which of the following statements is true?
Only one check box in a group can be selected
Only one radio button in a group can be selected
A label must be placed before every check box
A text field can return 9a number
Which method is not handled by a MouseListener?
MouseClicked
MouseEntered
MousePressed
MouseMoved
What command returns the label on a JButton object?
Event.getLabel();
Event.getSource();
Event.getCommand();
Event.getActionCommand();
{"name":"IAPP001 Multiple Choice", "url":"https://www.quiz-maker.com/QPREVIEW","txt":"Test your knowledge of Java programming concepts with this engaging quiz designed for enthusiasts and professionals alike. Covering topics such as OOP principles, design patterns, and method overloading, this quiz will challenge your understanding and reinforce your learning.78 thought-provoking questionsMultiple choice, text, and checkbox formatsAssess your skills and knowledge","img":"https:/images/course1.png"}
Powered by: Quiz Maker