Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

23 Questions of Computer Programming - Exam 3 | CSC 3405, Exams of Computer Science

Material Type: Exam; Professor: Wei; Class: Intro Computer Programming; Subject: Computer Science; University: Saint Joseph's University; Term: Unknown 1989;

Typology: Exams

Pre 2010

Uploaded on 08/19/2009

koofers-user-u58-2
koofers-user-u58-2 🇺🇸

10 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Practice Problems
CSC3405/3605
Write a recursive method to print a string backwards.
Write an iterative method to print a string backwards.
Write a recursive method to compute the factorial of a number.
Write an iterative method to compute the factorial of a number.
Draw an inheritance hierarchy to represent a shoe object. The base class should have derived
classes of Dress Shoes, Tennis Shoes and Boots.
Implement the base class in the shoe hierarchy in number 5 above.
public class Shoe
{ private String color;
private String designer;
private double size;
Derive a class named Dress Shoes from the base class created in number 6 above
public class DressShoe extends Shoe
{
private String type; //valid types include pumps, heels and flats
Derive a class named Tennis Shoes from the base class created in number 6 above.
public class TennisShoe extends Shoe
{
private String soleType;
private String canvasType;
1
pf3

Partial preview of the text

Download 23 Questions of Computer Programming - Exam 3 | CSC 3405 and more Exams Computer Science in PDF only on Docsity!

Practice Problems

CSC3405/

Write a recursive method to print a string backwards. Write an iterative method to print a string backwards. Write a recursive method to compute the factorial of a number. Write an iterative method to compute the factorial of a number. Draw an inheritance hierarchy to represent a shoe object. The base class should have derived classes of Dress Shoes, Tennis Shoes and Boots. Implement the base class in the shoe hierarchy in number 5 above. public class Shoe { private String color; private String designer; private double size; Derive a class named Dress Shoes from the base class created in number 6 above public class DressShoe extends Shoe { private String type; //valid types include pumps, heels and flats Derive a class named Tennis Shoes from the base class created in number 6 above. public class TennisShoe extends Shoe { private String soleType; private String canvasType;

  1. Derive a class named Boots from the base class created in number 9 above. public class Boot extends Shoe { private String heelType; //valid types include pumps, heels and flats
  2. Override the clone method inherited in the Dress Shoes class created in number 7 above.
  3. Override the clone method inherited in the Tennis Shoes class created in number 8 above.
  4. Override the clone method inherited in the Boots class created in number 9 above.
  5. Write a function that takes 2 arrays of 10 integers as arguments, and returns true if all of the elements in the first array match (in order) all of the elements of the second array.
  6. Write a function verify that takes an array of integers and the size of the array. The function returns true if the first element of the array is equal to the sum of the rest of the elements, false if not.
  7. Write a method(function) that reads integers from the input until the first non-zero integer is found. Return this number.
  8. Write a method (function) that takes an array of integers , the size of the array , and an integer skip as parameters. The method returns the sum of all numbers in the array, skipping the first skip elements.
  9. Write a program that reads an account balance (at the start of the month), the total value of deposits (for the month), the total value of withdrawals (for the month), and displays both the final balance and the net change to the balance.
  10. Write a program that reads integers count and marker from the input. It then reads count integers. Of these integers, the program prints the first integer after any time marker appears. For example, input of "8 0 0 2 3 0 0 -3 0 10" should result in output of "2 0 -3 10". Notice that in this input, count = 8 and marker = 0 and there are 8 integers following the input of 8 and 0.
  11. Write a function shuffle that takes an array of 20 integers and then shuffles the integers using the following algorithm: For each element X of the array, generate a random number N between 0 and 19, inclusive. Swap X with the element that corresponds to N.