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

Object Oriented Programming I - Quiz 1 | CMSC 131, Quizzes of Computer Science

Material Type: Quiz; Class: OBJECT-ORIENTED PROG I; Subject: Computer Science; University: University of Maryland; Term: Spring 2009;

Typology: Quizzes

Pre 2010

Uploaded on 07/29/2009

koofers-user-e74
koofers-user-e74 🇺🇸

5

(2)

10 documents

1 / 2

Toggle sidebar

Related documents


Partial preview of the text

Download Object Oriented Programming I - Quiz 1 | CMSC 131 and more Quizzes Computer Science in PDF only on Docsity!

CMSC 131 Pseudo Quiz #1 Spring 2009

These are some sample questions. There isn’t enough space here, so use your own paper to write the answers. The pseudo quiz is not graded or anything, its only purpose is to help you know which things may need more review before the exam.

  1. Convert each of the following from/to the base indicated:

(a) 23 10 = (^2) (b) 10011 2 = (^10)

  1. Define each of the following terms:

(a) byte (b) software (c) IDE (d) compiler (e) ASCII (f) method (g) byte code

  1. What does the term ”scope” mean when talking about local variables?
  2. What is a literal and how is it indicated in a program?
  3. What are the primitive types and what are their sizes?
  4. What are the operators on primitive types and what is their precedence?
  5. Write a public static void method that will take in two integers and draw a right, isoseles triangle using stars that has the height and the width of the larger of the two. If the larger is non-positive do nothing. For exmaple, if the call is triagle(2,4) the output would be:

**



  1. Write a public static void main method that will request and read integers from the user until the user puts in a negative value. The program will then write the value of the largest integer given, the value of the smallest integer, and the sum of all of the integers. For example if the user types: 2 5 8 9 3 1 0 2 -5 the output would be:

The largest = 9 The smallest = 0 The sum = 30

  1. Define a class to hold information about your car. The objects of this type should have properties that include the type of car (make or model), the number of people it can hold, and milage the car gets (all of these should be private). The car should have a constructor which takes in values for each of the three instance variables. The car should have a public instance method that returns to the user the milage of the car. The car should have another public instance method that returns the name for the type of car.

For the rest of this page, assume you are writing lines of code that would appear in a method that is not in the Car class created above, but you may assume it is within the same package.

  1. Create a variable that has a Honda that holds 4 people and gets 30 miles per gallon.
  2. Create a second variable that has a Toyota that holds 7 people and gets 20 miles per gallon.
  3. Write the lines of code that uses the two variables created above to print the type has the better gas milage.