CSCI 1010 Midterm Review
questions with 100% correct
answers
How are variables of a primitive type different from variables of a
class type?
The memory location of a variable of a primitive type contains a
data value itself. The memory location of a variable of a class type
contains a reference to an object.
A variable of a primitive type can be passed to a method as an
argument. A variable of a class type can not be passed to a method
as an argument.
A variable of a primitive type can be used as an instance variable in
a class. A variable of a class type can not be used as an instance
variable in a class.
A variable of a primitive type is initialized using the new keyword. A
variable of a class type is not. - answer The memory location of a
variable of a primitive type contains a data value itself. The memory
location of a variable of a class type contains a reference to an
object.
Which is the correct way to define a class called LightBulb with an
instance variable called wattage, with an accessor method and a
mutator method for that instance variable?
public class LightBulb
{
public int wattage;
public int getWattage()
{
return wattage;
public class LightBulb
{
private int wattage;
private int getWattage()
{
return wattage;
}
private void setWattage(int newWattage)
{
wattage = newWattage;
}
}
public class LightBulb
{
public int wattage;
private int getWattage()
{
return wattage;
}
private void setWattage(int newWattage)
,{
wattage = newWattage;
}
}
public class LightBulb
{
private int wattage;
public int getWattage()
{
return wattage;
}
public void setWattage(int newWattage)
{
wattage = newWattage;
}
} - answer D. public class LightBulb
{
private int wattage;
public int getWattage()
{
return wattage;
}
public void setWattage(int newWattage)
{
wattage = newWattage;
}
}
, Which Component of a computer is used to hold a running program
and its data?
A. The Central Processing Unit
B. The Main Memory
C. Auxiliary Memory
D. Input Output Devices - answer B. The Main Memory
How many bits make up a byte? - answer 8 bits
Which of the following is a program that translates high-level
language into low level language?
A. the operating system
B. A complier
C. an interpreter
d. a virtual machine - answer B. a compiler
What is the relationship between a class and an object?
A.A class is a blueprint for ccreating objects
B.an object is a blueprint for creating classes
C.class defines a behavior for an object
D. An object defines a behavior for a class - answer A class is a
blueprint for creating objects
What is inheritance? - answer a way of organizing classes by
identifying common attributes
What is an Algorithm? - answer A set of directions for solving a
problem
The benefits of buying summaries with Stuvia:
Guaranteed quality through customer reviews
Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.
Quick and easy check-out
You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.
Focus on what matters
Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!
Frequently asked questions
What do I get when I buy this document?
You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.
Satisfaction guarantee: how does it work?
Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.
Who am I buying these notes from?
Stuvia is a marketplace, so you are not buying this document from us, but from seller BRAINBOOSTERS. Stuvia facilitates payment to the seller.
Will I be stuck with a subscription?
No, you only buy these notes for $14.49. You're not tied to anything after your purchase.