Java Programming Concepts
39 Questions
5 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

Which of the following terms refers to the original class in inheritance?

  • Derived
  • Subclass
  • Parent (correct)
  • Child
  • A derived class cannot inherit properties of a superclass.

    False

    What type of relationship does proper inheritance create?

    Is-A

    An abstract method is a method that is declared without a ______.

    <p>body</p> Signup and view all the answers

    Match the following sorting strategies with their descriptions:

    <p>Selection Sort = Find the smallest value repeatedly and place it in the correct position Insertion Sort = Build a sorted list by inserting elements into their correct position Bubble Sort = Repeatedly swap adjacent elements if they are in the wrong order</p> Signup and view all the answers

    What does the compareTo method return if input1 is equal to input2?

    <p>0</p> Signup and view all the answers

    Polymorphism allows a single method to have multiple implementations.

    <p>True</p> Signup and view all the answers

    What is an abstract class?

    <p>It represents general concepts that derived classes have in common.</p> Signup and view all the answers

    The compareTo method compares two inputs and returns a value, which can be ______, 0, or +.

    <p>negative</p> Signup and view all the answers

    What is the primary purpose of a search pool?

    <p>To store a group of items for searching</p> Signup and view all the answers

    Which of the following scenarios could cause an exception to be thrown?

    <p>All of the above</p> Signup and view all the answers

    The call stack trace provides the method, file, and line number where the exception occurred.

    <p>True</p> Signup and view all the answers

    What is the purpose of a try-catch statement?

    <p>To test a block of code for errors and define a response if an error occurs.</p> Signup and view all the answers

    An exception is first thrown from the top of the call stack and, if not caught, it drops down to the ______ method.

    <p>previous</p> Signup and view all the answers

    Match the following standard I/O streams with their descriptions:

    <p>System.out = Represents the console window for output System.in = Represents the keyboard input System.err = Represents the console window for error output</p> Signup and view all the answers

    What is the condition that terminates the recursive processing known as?

    <p>Base case</p> Signup and view all the answers

    If there is no base case in recursion, it results in infinite recursion.

    <p>True</p> Signup and view all the answers

    Describe the difference between direct recursion and indirect recursion.

    <p>Direct recursion invokes itself, while indirect recursion involves a different method calling the recursive method.</p> Signup and view all the answers

    Each call to a recursive method creates a new ______ in which to work.

    <p>environment</p> Signup and view all the answers

    Which reserved word allows us to handle exceptions?

    <p>throw</p> Signup and view all the answers

    What operation does a stack use to add an item?

    <p>Push</p> Signup and view all the answers

    In a queue, the first item added is the first item removed.

    <p>True</p> Signup and view all the answers

    What is the key advantage of using a linked list over an array?

    <p>Dynamic size</p> Signup and view all the answers

    The last element added to a stack is the first to be removed, following the ______ policy.

    <p>LIFO</p> Signup and view all the answers

    Match the following data structures with their characteristics:

    <p>Stack = LIFO structure Queue = FIFO structure Linked List = Dynamic size Array = Fixed size</p> Signup and view all the answers

    Which of the following best describes a linked list?

    <p>A collection of nodes arranged in a linear order</p> Signup and view all the answers

    Stable sorting guarantees that elements with the same value remain in the same order in the output.

    <p>True</p> Signup and view all the answers

    What are the two primary functions used to maintain a stack?

    <p>Push and Pop</p> Signup and view all the answers

    A ________ is a data structure where each element points to its successor.

    <p>linked list</p> Signup and view all the answers

    Which of the following data structures can be implemented using references?

    <p>Stack</p> Signup and view all the answers

    What is the primary policy for a queue?

    <p>First in First Out (FIFO)</p> Signup and view all the answers

    The Enqueue operation removes items from the front of the queue.

    <p>False</p> Signup and view all the answers

    What do the head and tail of a queue represent?

    <p>The head keeps track of the index of the first element, and the tail keeps track of the index for the next insertion.</p> Signup and view all the answers

    In a binary tree, each node can have no more than ____ child nodes.

    <p>two</p> Signup and view all the answers

    Which of the following methods is used to add a new entry to a map?

    <p>.put()</p> Signup and view all the answers

    A directed graph does not have a defined root.

    <p>True</p> Signup and view all the answers

    What is a lambda function?

    <p>A short block of code that takes in parameters and returns a value.</p> Signup and view all the answers

    A ____ is a data collection that establishes a relationship between keys and values.

    <p>map</p> Signup and view all the answers

    What is a TreeMap?

    <p>A map that stores its entries in a sorted tree structure.</p> Signup and view all the answers

    Study Notes

    CSIT-112 Final Study Guide

    • This final exam will cover the entire course, emphasizing the second half.
    • Familiarize yourself with all concepts in the guide.

    Lecture 1

    • Inheritance: A fundamental object-oriented design technique for creating and organizing reusable classes.
    • Original Class References: Parent, Super, Base
    • Derived Class References: Child, Subclass
    • Inheritance Relationship: Is-A

    Lecture 2

    • Transitive Inheritance: A subclass inherits properties from the top-level class.
    • Abstract Method: A method declared without implementation (method header only).
    • Abstract Class: Represents general concepts shared by derived classes.

    Lecture 4

    • Polymorphism: Allows defining a single interface with multiple implementations.
    • Polymorphic Reference Behavior: A method called through a polymorphic reference might behave differently depending on the object.

    Lecture 5

    • Sorting: Arranging items in a specific order.
    • Selection Sort Strategy:
      • Find the smallest value.
      • Swap with the first element.
      • Find the next smallest value.
      • Swap with the second element.
      • Repeat until all elements are in their correct positions.

    Lecture 6

    • compareTo Method: Compares two inputs and returns a value.
      • Negative value if input1 < input2
      • Zero if input1 = input2
      • Positive value if input1 > input2
    • Insertion Sort Strategy: Insert each element into its correct position in the sorted portion of the array.

    Lecture 7

    • Search Pool: A group of items.

    Lecture 8

    • Exception: A problem or unusual situation arising during program execution.
    • Exception Scenarios: Dividing by zero, attempting to read a non-existent file, array index out of bounds, etc.
    • Call Stack Trace: Shows the sequence of method calls leading up to the exception.
    • Includes: the method, file, and line number where the exception originated.

    Lecture 9

    • Try-Catch Statement: Allows testing code blocks for errors, handling potential issues.
    • Exception Propagation: Handles exceptions not caught by the immediate method by passing them up the call stack.

    Lecture 10

    • Standard I/O Streams: System.out, System.in, System.err.
      • System.out: Console output.
      • System.in: Keyboard input.
      • System.err: Error output.

    Lecture 11

    • Recursion: Defining something in terms of itself.
    • Base Case: A condition that halts the recursive process.
    • Recursive Techniques Examples: Problems covered so far.

    Lecture 12

    • Direct Recursion: A method calls itself directly.
    • Indirect Recursion: A method calls another method, which then calls the original method.
    • Example Recursive Functions: sum, factorial.

    Lecture 13

    • Collection: An object that stores other objects.
    • Stable Sorting: Maintains the relative order of elements with equal values.
    • Unstable Sorting: Does not guarantee the relative order of equal elements.
    • Abstract Data Type (ADT): A collection of data and operations.
    • Static Data Structure: Fixed size.
    • Dynamic Data Structure: Resizable.
    • References/Pointers: Dynamic linking between objects.
    • Data Structures: Trees, Linked Lists, Graphs.

    Lecture 14

    • Stack: A linear data structure following LIFO (Last-In, First-Out) principle.
    • Stack Operations: Push, Pop, Top.
    • Stack Representation: Visual Representation

    Lecture 15

    • Non-Linear Data Structures: Trees, Graphs.
    • Tree Characteristics: Nodes, edges, root, parent, children, key, height.
    • Binary Tree: Each node has a maximum of two children.
    • Leaf Node: A node with no children.

    Lecture 16

    • Maps: Collections that store key-value pairs.
    • Efficiency in Maps: Efficient for finding values given a key.
    • Map Implementations: TreeMap, HashMap.
    • Key-value Pairs: Examples.
    • Methods (HashMap): put, get.
    • Lambda Expressions: Used for concise, functional-style programming.
    • Lambda Limitations: Cannot contain variables, assignments, or statements (if or for loops).

    Studying That Suits You

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

    Quiz Team

    Related Documents

    CSIT-112 Final Study Guide PDF

    Description

    Test your knowledge on Java programming with this quiz covering key concepts such as inheritance, polymorphism, abstract classes, and exception handling. Each question will challenge your understanding of important programming principles essential for developing robust applications.

    More Like This

    Use Quizgecko on...
    Browser
    Browser