Given is an adjacency matrix and a starting index.
Complete the depth first traversal method. Comments noted with //_________________ are...
Search Results
Searching for: Java
Individual Exercises
When a method is directly recursive, what does it call?
If the class Pug
extends the class Dog
, what can't be said about the classes?
Write a function in Java that takes the int array arr
and returns a new array with each number being doubled. Be sure to make use of...
What would be the Big O Complexity for the following method?
public static void arrayDoubleValue(int[] nums, int[][] nums2) { for (int i...
Design a class Dog, making sure it is appropriately encapsulated. The class will have the properties 'name' and 'breed' (both Strings), a...
Given an int[] nums
array, return the sum of the first five elements from the array. Note that nums
could have fewer than five elements,...
Create an enhanced for loop that iterates to each String in the array words
and returns true when there is at least one String with more...
"Determine which exception is needed for each case and put them in the corresponding catch statement with the appropriate variable. Do ...
Complete the method so that the number num
is set to index point index
in the array named array
. Be sure to handle the exception with the...
Surround the appropriate lines of code with a try catch block so that first, an exception is caught when the String index is out of...
Create a method that returns the third character from the String word
. Be sure to use a try catch block and use the appropriate exception...
Considering the following lines of code, what will be the output?
try { String str = null; System.out.println(str.charAt(0)); }...
Return an array with the same contents, but double the size of the array passed in. The new slots will be filled with zeros. Use the...
In mathematics, the Fibonacci numbers are the numbers in the following integer sequence, characterized by the fact that every number...
Write a function findEvenQueue
that returns the first even number in the Queue. The function looks at the value at the front of the queue...
Return the index of first four in an array. Return -1 if there are none.
Write the method findMin
that will return the smallest number in an array of integers.
The following method takes an integer array as a parameter. Write code that loops through the array to find the value 1. If 1 is found,...
Return the index of the last occurrence of a given number in an array. Return -1 if the number is not in the array.
[Based on an exercise at https://codeworkout.cs.vt.edu/]
Given a string, return the string made of its first two chars, so the string...
The following method is a Selection Sort method. Within the method, there is an error on one line. You job is to find that line and fix...
Using generics in your program can be very useful considering generic methods and generic classes can handle different datatypes....
You have been handed a mysterious piece of data by an unknown person. Judging by his shifty eyes and maniacal laughter you don't think he...
Given a class Answer<E>
, write a method that converts argument e
into String and returns that value. If the value is a primitve, (...