AOOP REVIEWER
80 Questions
39 Views

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to Lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

What does the term 'encapsulation' refer to in object-oriented programming?

  • The restriction of access to an object's data. (correct)
  • The definition of attributes and behaviors in a class.
  • The process of creating an object from a class.
  • The ability of an object to perform actions on its own.
  • What are 'attributes' in the context of object-oriented programming?

  • The instances created from a class.
  • The interactions between different objects.
  • The methods that define an object's capabilities.
  • The characteristics or properties of an object. (correct)
  • Which keyword is used to refer to the current instance of a class?

  • this (correct)
  • current
  • self
  • instance
  • What is a constructor in object-oriented programming?

    <p>A special method called to create an instance of a class. (B)</p> Signup and view all the answers

    How does the concept of 'abstraction' benefit users?

    <p>By hiding unnecessary details from the user. (A)</p> Signup and view all the answers

    Which of the following components primarily defines the behavior of an object?

    <p>Methods (A)</p> Signup and view all the answers

    What does the term 'anthropomorphic' mean in relation to objects?

    <p>Objects need direction from others to function. (D)</p> Signup and view all the answers

    Which statement best describes the relationship between classes and objects?

    <p>A class is a blueprint, and an object is an instance of that blueprint. (A)</p> Signup and view all the answers

    What does polymorphism in object-oriented programming allow?

    <p>Assigning a subclass to its superclass type. (D)</p> Signup and view all the answers

    Which keyword is used to relate a field to the class and not to the instance?

    <p>static (D)</p> Signup and view all the answers

    What type of relationship does aggregation represent?

    <p>Two objects are independently associated but can exist separately. (B)</p> Signup and view all the answers

    What does the 'extends' keyword signify in Java?

    <p>Inheritance from a parent class. (A)</p> Signup and view all the answers

    Which of the following is a purpose of using generics in Java?

    <p>To provide abstraction over types. (A)</p> Signup and view all the answers

    What does the Serializable interface enable in Java?

    <p>Converting an object's state into a byte stream. (C)</p> Signup and view all the answers

    Which of these is NOT an advantage of the MVC architecture?

    <p>Difficulties in testing individual components. (B)</p> Signup and view all the answers

    What is the primary role of the Model in the MVC architecture?

    <p>To manage the core functionality and data logic. (B)</p> Signup and view all the answers

    Which of the following best describes a composition relationship?

    <p>One object relies on the other for its existence. (B)</p> Signup and view all the answers

    What is the purpose of the serialVersionUID in Java?

    <p>To ensure that objects are serialized correctly. (C)</p> Signup and view all the answers

    Which keyword is used to make a field or method visible only to subclasses?

    <p>protected (C)</p> Signup and view all the answers

    What does the term 'interface' in Java refer to?

    <p>A set of method signatures with no implementations. (D)</p> Signup and view all the answers

    How are generic bounds defined in Java?

    <p>Using the 'extends' keyword for upper bounds. (B)</p> Signup and view all the answers

    What method does the View implement to apply changes from models?

    <p>void update(Observable obj, Object data) (A)</p> Signup and view all the answers

    Which component is responsible for managing user interactions in the MVC architecture?

    <p>Controller (A)</p> Signup and view all the answers

    Which of the following best describes an Inner Class?

    <p>A class defined inside another class. (C)</p> Signup and view all the answers

    What is the primary purpose of the Observable class in Java?

    <p>To notify observers when the model changes. (C)</p> Signup and view all the answers

    Which of the following is NOT a responsibility of a Database Management System (DBMS)?

    <p>Data Encryption (B)</p> Signup and view all the answers

    Which SQL command is used to create a new database?

    <p>CREATE DATABASE database_name; (B)</p> Signup and view all the answers

    What type of inner class is usually nameless and used once?

    <p>Anonymous Inner Class (B)</p> Signup and view all the answers

    Which operation is NOT part of the CRUD functionality of SQL?

    <p>Store (D)</p> Signup and view all the answers

    What does the term 'Serialization' refer to in programming?

    <p>The conversion of an object into a byte stream. (A)</p> Signup and view all the answers

    In the context of a database table, what do columns represent?

    <p>Attributes or characteristics of the entity. (D)</p> Signup and view all the answers

    What is the main feature of Data Definition Language (DDL)?

    <p>Creates and manipulates database objects. (D)</p> Signup and view all the answers

    Which term describes the process of an application client creating a connection to a database using JDBC?

    <p>Database Connectivity (D)</p> Signup and view all the answers

    Which of the following scenarios would most likely use an Anonymous Inner Class?

    <p>Implementing a unique listener for a button click. (B)</p> Signup and view all the answers

    Which of the following accurately describes the role of the Model component in MVC architecture?

    <p>It contains the data and business logic of the application. (A)</p> Signup and view all the answers

    What is the primary function of the garbage collection thread in Java?

    <p>To free any memory that is no longer needed (B)</p> Signup and view all the answers

    Which primitive data type in Java has the smallest size?

    <p>byte (C)</p> Signup and view all the answers

    In Java, which access modifier allows a subclass to access variables, methods, and constructors from a superclass?

    <p>protected (C)</p> Signup and view all the answers

    What is referred to as the process where a subclass provides a specific implementation of a method already defined in its parent class?

    <p>Method overriding (C)</p> Signup and view all the answers

    What is the default value of a char variable in Java?

    <p>'\u0000' (B)</p> Signup and view all the answers

    Which data type is suitable for storing whole numbers in a database?

    <p>INT (B)</p> Signup and view all the answers

    What does the UNIQUE constraint ensure for a database field?

    <p>Field values must be unique across instances (A)</p> Signup and view all the answers

    What is the purpose of the DELETE command in SQL?

    <p>To remove rows from a table (A)</p> Signup and view all the answers

    What does the AUTO_INCREMENT feature do in a database field?

    <p>Increments the field's value automatically with each new entry (C)</p> Signup and view all the answers

    Which SQL statement retrieves all data of students in their first year?

    <p>SELECT * FROM students WHERE year_level = 1; (A)</p> Signup and view all the answers

    What SQL command would you use to increment the year level of all 'Information Technology' students by 1?

    <p>UPDATE students SET year_level = year_level + 1 WHERE program = 'Information Technology'; (A)</p> Signup and view all the answers

    Which type of JDBC driver is characterized by not requiring any code installed on the client?

    <p>Type 3: JDBC-Net pure Java (A)</p> Signup and view all the answers

    Which SQL command will permanently erase a database instance?

    <p>DROP DATABASE (B)</p> Signup and view all the answers

    What is the result of executing 'DELETE FROM students;' without a WHERE clause?

    <p>Removes all rows from the students table (A)</p> Signup and view all the answers

    Which SQL function would you use to retrieve distinct program names for students whose names start with 'X'?

    <p>SELECT DISTINCT program FROM students WHERE name LIKE 'X%'; (D)</p> Signup and view all the answers

    What is the primary purpose of the JDBC Driver?

    <p>To connect Java programs to a database (D)</p> Signup and view all the answers

    What constraint would you use to ensure a field in a table can never be left empty?

    <p>NOT NULL (D)</p> Signup and view all the answers

    Which command is used in SQL to add new rows to a table?

    <p>INSERT (A)</p> Signup and view all the answers

    In the context of SQL, what does the term 'Data Manipulation Language (DML)' refer to?

    <p>A language for manipulating data within the database (A)</p> Signup and view all the answers

    What does the executeUpdate() method return when executing an INSERT statement?

    <p>An int representing affected rows (A)</p> Signup and view all the answers

    What is the purpose of a ResultSet in Java Database Connectivity?

    <p>To hold data retrieved from a database (B)</p> Signup and view all the answers

    Which method is recommended to ensure that database connections are closed?

    <p>close() in a finally block (C)</p> Signup and view all the answers

    In a multithreaded application, how do threads primarily share memory?

    <p>By sharing access to the same memory space (A)</p> Signup and view all the answers

    What does the run() method in a Thread class do?

    <p>Initiates the thread's execution (B)</p> Signup and view all the answers

    Which mechanism is now considered the correct way to stop a thread in Java?

    <p>Using a boolean variable in the run method (B)</p> Signup and view all the answers

    Which of the following is a state of a thread?

    <p>Running (D)</p> Signup and view all the answers

    What is the default priority assigned to a thread in Java?

    <p>5 (C)</p> Signup and view all the answers

    What is one drawback of using a simple scheduling algorithm for thread execution?

    <p>It can lead to thread starvation. (D)</p> Signup and view all the answers

    What is a common purpose of the yield() method in Java threading?

    <p>To release CPU time voluntarily (D)</p> Signup and view all the answers

    Which interface is commonly used to create threads in a way that allows more flexibility than subclassing the Thread class?

    <p>Runnable (C)</p> Signup and view all the answers

    Why should the stop() method not be used in thread management?

    <p>It can lead to deadlocks. (A)</p> Signup and view all the answers

    What does the setPriority(int aPriority) method do for a thread?

    <p>Defines the order in which threads are executed (C)</p> Signup and view all the answers

    What happens when a thread cannot obtain a lock on a synchronized method?

    <p>The thread goes into the wait queue until the lock becomes available (D)</p> Signup and view all the answers

    Which method can be used to allow a thread to voluntarily relinquish the CPU?

    <p>yield() (D)</p> Signup and view all the answers

    What is the purpose of the sleep(time) method?

    <p>To stop the thread execution for a specific amount of milliseconds (A)</p> Signup and view all the answers

    What does synchronization ensure within synchronized methods?

    <p>That only one thread can access critical data at a time (B)</p> Signup and view all the answers

    What must be done to a method to make it synchronized in Java?

    <p>Add the synchronized modifier (C)</p> Signup and view all the answers

    Which of the following best describes the states of a thread?

    <p>Created, Running, Blocked, Dead (B)</p> Signup and view all the answers

    What describes a class in the context of object-oriented programming?

    <p>A blueprint from which objects are created (D)</p> Signup and view all the answers

    What keyword is used to create a subclass from a parent class?

    <p>extends (A)</p> Signup and view all the answers

    What is method overriding?

    <p>Changing the implementation of a method in a subclass with the same name (A)</p> Signup and view all the answers

    Which statement correctly reflects the relationship between classes and interfaces in Java?

    <p>Classes can implement multiple interfaces (A)</p> Signup and view all the answers

    What does the term 'polymorphism' refer to in programming?

    <p>The ability to present the same interface for different underlying forms (A)</p> Signup and view all the answers

    What describes an association relationship in terms of object orientation?

    <p>One object relies on another object for its functionality (C)</p> Signup and view all the answers

    Which of the following best describes abstraction in object-oriented programming?

    <p>Hiding complex details and showing only essential features (A)</p> Signup and view all the answers

    Flashcards

    Object

    An abstraction of a real-world concept in programming.

    Instance

    A specific realization of an object model.

    Attributes (State)

    Characteristics of an object; what it is.

    Behavior

    Capabilities of an object; what it can do.

    Signup and view all the flashcards

    Class

    A blueprint for creating objects (a template).

    Signup and view all the flashcards

    Constructor

    Special method called to create an object instance.

    Signup and view all the flashcards

    Encapsulation

    Restricting access to object data (security).

    Signup and view all the flashcards

    Accessor/Getter

    Method for retrieving object data.

    Signup and view all the flashcards

    Default Constructor

    A constructor provided by the compiler when no constructors are defined in a class. It initializes object's fields.

    Signup and view all the flashcards

    Accessor Method

    A method used to retrieve the value of a field in a class.

    Signup and view all the flashcards

    Abstraction

    Hiding complex details from the user, exposing only essential information.

    Signup and view all the flashcards

    Association

    A relationship between two objects where one object uses another.

    Signup and view all the flashcards

    Composition

    A stronger association: one object relies on the existence of another.

    Signup and view all the flashcards

    Aggregation

    A weaker association: objects can exist independently.

    Signup and view all the flashcards

    Inheritance

    A 'is-a' relationship where a class (child) inherits properties and methods from another class (parent).

    Signup and view all the flashcards

    Polymorphism

    Treating objects of different classes in a uniform way, via inheritance.

    Signup and view all the flashcards

    Interface

    A specification for a class, defining method signatures without implementation.

    Signup and view all the flashcards

    Generics

    A way to write reusable code that works with different data types without sacrificing type safety.

    Signup and view all the flashcards

    Serialization

    Converting an object into a byte stream for storage or transmission.

    Signup and view all the flashcards

    Serializable Interface

    The interface that must be implemented for an object to be serializable.

    Signup and view all the flashcards

    MVC Architecture

    A software design pattern that separates an application into Model, View, and Controller components.

    Signup and view all the flashcards

    Model (MVC)

    The component that holds data and business logic in MVC architecture.

    Signup and view all the flashcards

    Observable class

    Java class that enables a model to broadcast changes, notifying observers.

    Signup and view all the flashcards

    View (MVC)

    MVC component representing data to the user.

    Signup and view all the flashcards

    Controller (MVC)

    MVC component handling user interaction, calls model and view.

    Signup and view all the flashcards

    Observer

    Interface in Java for responding to model changes.

    Signup and view all the flashcards

    Inner Class

    A class defined inside another class.

    Signup and view all the flashcards

    Anonymous Inner Class

    Nameless class, defined and used at once, often in method arguments.

    Signup and view all the flashcards

    JDBC

    Java Database Connectivity API for database interaction.

    Signup and view all the flashcards

    Database

    Organized collection of structured data.

    Signup and view all the flashcards

    DBMS

    Database Management System; software to manage databases.

    Signup and view all the flashcards

    Table (database)

    Two-dimensional structure with rows and columns, stores data in a database.

    Signup and view all the flashcards

    SQL

    Structured Query Language, standard language for database operations.

    Signup and view all the flashcards

    CRUD

    Create, Read, Update, Delete - basic database operations.

    Signup and view all the flashcards

    DDL

    Data Definition Language, for defining database structure.

    Signup and view all the flashcards

    CREATE DATABASE

    SQL command to create a database.

    Signup and view all the flashcards

    CREATE TABLE

    SQL command to define a table in a database.

    Signup and view all the flashcards

    Bytecode

    A special language understood by the Java Virtual Machine (JVM), used to execute Java programs.

    Signup and view all the flashcards

    Garbage Collection

    The process of automatic memory management in Java, where unused objects are identified and removed from memory.

    Signup and view all the flashcards

    Class Loader

    A component of the JVM that loads all necessary Java classes into memory for execution.

    Signup and view all the flashcards

    Type Parameter

    A variable, usually represented by a capital letter (e.g., 'T'), used in generic code to represent a placeholder for any type.

    Signup and view all the flashcards

    Method Overriding

    When a subclass provides its own implementation of a method already defined in its parent class.

    Signup and view all the flashcards

    executeQuery()

    Executes SELECT statements in SQL, retrieving data as a ResultSet object.

    Signup and view all the flashcards

    executeUpdate()

    Executes INSERT, UPDATE, or DELETE statements in SQL, returning the number of affected rows.

    Signup and view all the flashcards

    ResultSet

    Holds data retrieved from a database after executing an SQL query.

    Signup and view all the flashcards

    How to iterate through ResultSet?

    Use a while loop with the 'rs.next()' method to move through the results one row at a time.

    Signup and view all the flashcards

    Connection Object's 'close()' Method

    Closes the connection to the database, releasing resources.

    Signup and view all the flashcards

    finally Block

    Ensures code always executes, even if an exception occurs, often used for closing resources.

    Signup and view all the flashcards

    Multithreading

    Executing multiple threads concurrently within the same memory space of a program.

    Signup and view all the flashcards

    Multi-processing

    Executing multiple processes concurrently, each with its own memory space.

    Signup and view all the flashcards

    Thread

    An independent unit of execution within a program, sharing memory with other threads.

    Signup and view all the flashcards

    Thread Class

    Represents a Java thread, providing methods to control its state and execution.

    Signup and view all the flashcards

    Thread States

    States that a thread can be in: Created, Running, Blocked, Dead.

    Signup and view all the flashcards

    run() Method

    The method inside a Thread object that contains the code to be executed by the thread.

    Signup and view all the flashcards

    Thread.start()

    Initiates the execution of a thread, causing the run() method to be called.

    Signup and view all the flashcards

    Runnable Interface

    Defines a run() method, allowing any class to implement the Runnable interface and be executed as a thread.

    Signup and view all the flashcards

    Thread Priorities

    A numerical value (1-10) assigned to a thread to indicate its relative importance.

    Signup and view all the flashcards

    SQL Data Types

    INT for whole numbers, VARCHAR for variable-length strings (with a maximum length), and DOUBLE for numbers with decimals.

    Signup and view all the flashcards

    Primary Key

    A unique identifier for a record/row in a table; prevents duplicate values and ensures every record has a value for that field.

    Signup and view all the flashcards

    Unique Constraint

    Ensures that a field contains unique values across all rows in the table.

    Signup and view all the flashcards

    NOT NULL Constraint

    Forces a field to always have a value; prevents empty values.

    Signup and view all the flashcards

    AUTO_INCREMENT

    Automatically assigns unique integer values to a field, typically used for IDs.

    Signup and view all the flashcards

    DROP DATABASE

    Deletes an entire database and all its tables and data.

    Signup and view all the flashcards

    DROP TABLE

    Deletes a specific table from a database.

    Signup and view all the flashcards

    DML (Data Manipulation Language)

    Commands used to manipulate existing data within a database.

    Signup and view all the flashcards

    SELECT Statement

    Used to retrieve data from one or more tables in a database.

    Signup and view all the flashcards

    INSERT Statement

    Adds new rows of data to a table

    Signup and view all the flashcards

    UPDATE Statement

    Modifies existing data in a table

    Signup and view all the flashcards

    DELETE Statement

    Removes rows from a table.

    Signup and view all the flashcards

    JDBC Driver

    A software component that enables a JDBC application to connect to a database server.

    Signup and view all the flashcards

    Type 4 JDBC Driver

    A pure Java driver that communicates directly with the database server over a network connection.

    Signup and view all the flashcards

    Busy-Wait

    A thread continuously checks a flag, consuming CPU cycles without doing useful work.

    Signup and view all the flashcards

    Run Queue

    Where ready-to-run threads are kept, waiting for their turn on the CPU.

    Signup and view all the flashcards

    Wait Queue

    Where threads are temporarily paused, waiting for a specific event or condition.

    Signup and view all the flashcards

    Yield()

    A function that voluntarily releases the CPU, allowing another thread to run.

    Signup and view all the flashcards

    Sleep(time)

    A function that puts a thread to sleep for a specified duration, preventing it from using the CPU.

    Signup and view all the flashcards

    Synchronization

    A mechanism to control access to shared resources, preventing multiple threads from modifying them simultaneously.

    Signup and view all the flashcards

    Object Lock

    A mechanism in Java that allows only one thread to access an object's methods at a time, preventing conflicts.

    Signup and view all the flashcards

    Synchronized Method

    A method that acquires an object's lock before executing, ensuring exclusive access.

    Signup and view all the flashcards

    Study Notes

    Topic 1: Generics

    • Generics allow objects to accept different types of parameters instead of being limited to a specific type.
    • A generic parameter, like T in a generic method, can accept any data type.

    Topic 2: Generic Method Syntax Example

    • The provided code snippet demonstrates a generic method copy that copies elements from one array (src) to another (dest).
    • The method takes two arrays as input: src (source) and dest (destination).
    • S and T are type parameters, indicating the types of elements in the source and destination arrays.

    Studying That Suits You

    Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

    Quiz Team

    Description

    goodluck

    More Like This

    Generics Concepts Flashcards
    7 questions
    Java Generic Classes Overview
    36 questions
    Generic Programming in Java
    24 questions

    Generic Programming in Java

    WellBredConsciousness5838 avatar
    WellBredConsciousness5838
    Use Quizgecko on...
    Browser
    Browser