16 Questions
Which keyword in Java is used to instantiate objects?
new
What is the keyword used in inheritance?
extends
What is the purpose of the try-catch block in Java?
To handle exceptions that may occur within a block of code
What does the term 'method signature' refer to in Java?
The name and parameter list of a method
Which keyword is used to prevent a class from being subclassed?
final
What OOP concept has a base class and subclass?
Inheritance
What is the correct way to properly connect an interface named Assessment from a class?
public class Assessment implements Compute { }
What is the correct way to instantiate an object?
NewClass obj = new NewClass();
What type of loop is popular for having all the components in one line?
For Loop
What keyword in Java is used to reference a variable that is used to refer to the parent class when working with objects?
super
What is the value at index 2 if the given array code is String names = {"Jordan", "Curry", "Lebron", "Kobe"};?
Lebron
Which is the most restricted type of access modifier?
private
What library is used to create an object that will let you input a value from the keyboard?
import java.util.Scanner;
What OOP concept involves defining multiple methods with the same name but different parameter lists?
Polymorphism
What is the correct way of creating a setter method?
public void setName(String name) { this.name = name; }
Which OOP concept involves bundling data and methods that operate on the data into a single unit?
Encapsulation
Study Notes
Loops
- For Loop is popular for having all the components in one line.
- While Loop checks the condition first before doing the statements.
Object-Oriented Programming (OOP) Concepts
- Polymorphism involves defining multiple methods with the same name but different parameter lists.
- Encapsulation bundles data and methods that operate on the data into a single unit.
- Inheritance has a base class and subclass, creating a chain of inheritance.
Variables and Methods
- 'super' is the keyword used to reference a variable that is used to refer to the parent class when working with objects.
- 'this' is used to reference the current object.
- 'new' is the keyword used to instantiate objects.
- A setter method is used to initialize objects of a class, and the correct way to create a setter method is
public void setName(String name) { this.name = name; }
.
Arrays and Collections
- The value at index 2 in the given array code
String names = {"Jordan", "Curry", "Lebron", "Kobe"};
isLebron
. - The correct way to declare an ArrayList of integers in Java is
ArrayList numbers = new ArrayList();
.
Access Modifiers
-
private
is the most restricted type of access modifier.
Input/Output
- The
java.util.Scanner
library is used to create an object that will let you input a value from the keyboard.
Constructors and Method Signatures
- A constructor refers to a special method used to initialize objects of a class.
- The method signature refers to the name and parameter list of a method.
Inheritance and Subclassing
- The keyword
extends
is used in inheritance. - The
final
keyword is used to prevent a class from being subclassed.
Generics and Interfaces
- Using Generics, it is not possible to create a single class that works with a specific data type.
- The correct way to properly connect an interface named
Assessment
from a class ispublic class Assessment implements Compute{ }
. - The correct way to create a bounded type generic class is
public class Box
.
Exception Handling
- The purpose of the try-catch block in Java is to handle exceptions that may occur within a block of code.
Test your knowledge of programming basics, including loop types, object-oriented programming concepts, and variable usage.
Make Your Own Quizzes and Flashcards
Convert your notes into interactive study material.
Get started for free