



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
A series of questions and answers related to java data structures, focusing on topics such as linked lists, arrays, recursion, and object-oriented programming principles. It covers fundamental concepts like traversing linked lists, memory allocation, and the software development life cycle. The questions are designed to test understanding of core data structure concepts and their implementation in java, making it a useful resource for students studying computer science or preparing for exams. It also touches on adts and modular programming, providing a comprehensive overview of essential topics in data structures and algorithms. Useful for students who want to test their knowledge about data structures and algorithms in java. It provides a series of questions and answers that cover a wide range of topics, from basic concepts to more advanced topics.
Typology: Exams
1 / 7
This page cannot be seen from the preview
Don't miss anything!




In Java, all arguments are passed to methods by value, except for objects and arrays. - Correct Answers -True Every Java class is a subclass of either another Java class or the Object class. - Correct Answers -True Java allows programmers to perform operations on reference values - Correct Answers -False In Java, multiple class inheritance is possible since a new subclass can directly inherit the attributes (i.e. data and methods) of more than one class, including the Object class.
public static int Mystery (int N) { if (N > 0) return 1 + Mystery(N / 10); else return 0; } - Correct Answers -It computes the number of decimal digits in N In the box trace for a recursive method, a new box (i.e. activation record) is created each time: - Correct Answers -the method is called Consider the following Java program. What is output by the program? public static void main( void ) { int a, b, result; a = 3; b = 4; result = value( a, b ); System.out.printf("%d\n",result); } public static int value( int x, int n ) { if ( n > 0 ) return x * value( x, n - 1 ); else return 1; } - Correct Answers -
p = null; r = q; - Correct Answers -p An array of objects is actually an array of references to the objects. - Correct Answers - True When an object is passed to a method as an actual parameter, the method receives a copy of the object, not a reference to the object. - Correct Answers -False Equality operators (== and !=) used with objects will compare the addresses of objects, not the values associated with those objects. - Correct Answers -True heap - Correct Answers -block of storage within which pieces are allocated and freed in some relatively unstructured manner dangling references - Correct Answers -an access path that continues to exist after the lifetime of the associated data object stack - Correct Answers -Memory allocations for automating storage of local variables and formal parameters in methods. Garbage - Correct Answers -an object whose access paths have all been destroyed It is possible for a dangling reference to exist in Java. - Correct Answers -False A linked list does not always have a head. - Correct Answers -False A linked list with a null head is full. - Correct Answers -False In a reference-based linked list, the data field next in the last node is set to null. - Correct Answers -True What best describes the purpose of this code snippet: for (Node curr = head; curr != null; curr = curr.getNext()) { // code goes in here } - Correct Answers -Traversing a linked list. When deleting a node from an ordered linked list, all cases involve at least a partial traversal of the list in order to find the location of the node to be deleted. - Correct Answers -True A reference-based implementation of the ADT list does not shift items during insertion or deletion. - Correct Answers -True
A reference based implementation of the ADT list does impose a fixed maximum list length. - Correct Answers -False Select all of the following which are TRUE of array-based implementations of ADT lists when compared to a reference-based implementation. - Correct Answers -Requires less memory Select all of the following which are TRUE of array-based implementations of ADT lists when compared to a reference-based implementation. - Correct Answers -Fixed size Select all of the following which are TRUE of array-based implementations of ADT lists when compared to a reference-based implementation. - Correct Answers -Potential for over allocation of space The storage density factor of a reference-based implementation of an ADT list is less than 1. - Correct Answers -True In an array-based implementation of an ADT list, the access time varies. - Correct Answers -False In a reference-based implementation of an ADT list: - Correct Answers -an item explicitly references the next item. An array-based implementation of an ADT list: - Correct Answers -requires less memory to store a data element than a reference-based implementation. Java does not support class inheritance. - Correct Answers -False In ______ recursion, there can be multiple activation's of the same method existing at the same time. - Correct Answers -indirect A test for the base case enables recursive calls to stop. - Correct Answers -True CompareTo cannot compare two different types of numbers. - Correct Answers -True Given the code snippet below, which of the following best represents the output: Integer x = 5; System.out.println(x.compareTo(3)); - Correct Answers - Recursion cannot be used for list traversal or node insertion. - Correct Answers -False
In backtracking, you use recursion to explore all possible solutions until you find the best one - Correct Answers -True Language grammars are never defined recursively. - Correct Answers -False What is the value of the postfix expression: 6 7 + 8 2 - * - Correct Answers - What is the value of the prefix expression: - * 3 8 + 6 5 - Correct Answers - Which of the following is the postfix form of the prefix expression: * + a b c - Correct Answers -a b + c *