Students
Teachers & SchoolsStudents
Teachers & SchoolsAPCS: Classes and Objects Drill 2, Problem 1. Which of the following is true?
AP | AP Computer Science |
AP Computer Science | Classes and Objects |
Computer Science | AP Computer Science |
Language | English Language |
Standard Operations and Algorithms | Operations on data structures |
Test Prep | AP Computer Science |
vehicle is to be written including the following data members
and method data members representing a vehicle's year manufacturer model
and number of wheels Possessor methods get you factoring in
model All right so which of the following is true
and hear the pencil answer All right well looks like
we're building a super glass called vehicle and creating a
series of variables within it as well as associate id
access or methods to access those variables Right Right Well
the entire point of an accessory method is having it
act as a middleman that retrieves the data held from
a private variable So we can already cross out any
potential answers that suggest we declare any variables Public option
b suggests we declare manufacturer to be a private inner
jer Well the private b**** is right on the money
but an imager isn't gonna work We'll need a string
to store text right there Watching d says model should
be either a private string or public imager to represent
a model number We already know that a public variables
no good But what about private strength Well being that
we're representing a model number and image it would be
preferable here Intend your yeah but wait Couldn't least or
a model number is a string Well it'd just be
a string and numbers instead of an imager But all
in all would it work practically the same right Maybe
Well if we know that our model number variable will
on ly be storing digits it's a little wiser to
use an imager Not only is it impossible to accidentally
insert text into an imager but the imager data type
also used a little bit less memory than a small
strength imager would definitely be the most efficient choice here
So it's a no on the option e says my
years should be a private imager right on the money
and imager would be perfect Thie year will never be
anything other than a whole number and it will always
be a low enough number that we can stick with
the imager data type unless we're still using this program
in the year two billion one hundred forty seven million
four hundred three thousand six hundred forty seven which is
the limit of the energy data type In that case
let's Make a mill note to come back and do
a code on it in about two billion years Deal 00:02:37.613 --> [endTime] or no deal