PCAP Exam QuestionsBrowse all questions from this exam

PCAP Exam - Question 35


A variable stored separately in every object is called:

Show Answer
Correct Answer: D

In object-oriented programming, a variable stored separately in every object is known as an instance variable. An instance variable is unique to each instance of a class, meaning that each object of the class can hold different values for this variable. This contrasts with class variables, which are shared among all instances of a class.

Discussion

13 comments
Sign in to comment
locloc91Option: D
Aug 14, 2019

The answer should be D!?

PygineerOption: D
Dec 5, 2019

answer is D

SophieSuOption: D
Nov 25, 2019

Answer should be D

anjuvinayanOption: D
Nov 29, 2019

an instance variable is correct answer

pshdreddyOption: D
May 17, 2020

Answer should be D

AdeshinaOption: D
Dec 12, 2022

D. an instance variable In object-oriented programming, a variable that is stored separately in every object of a class is called an instance variable. An instance variable is associated with a specific instance of a class, and its value is unique to that instance. This means that if you have two objects of the same class, each object can have its own unique value for an instance variable.

pedrorodrigwezOption: A
Jul 5, 2020

Correct Answer is A. Python does not use variables per se, in fact, "variables" in python are just references to objects.

WorkingDaddy
Jul 14, 2020

Even so, python.org sayeth: "...instance variables are for data unique to each instance and class variables..." https://docs.python.org/3/tutorial/classes.html So with Python.org's definition of "instance variable" in mind, D is correct. The "just references to objects" thing is, I think, a little beyond the scope of the PCAP exam...?

imsaadOption: D
Jul 24, 2020

should be D

puneetkOption: B
Jul 24, 2020

Wondering, if Class Variable (B) is the right answer? Its "...A variable stored separately in every Object...", could mean a variable X in class definition, accessed by object O1, O2...On for their own copies.

AshitAdhikari
Jul 5, 2021

No. Every object shares a single copy of the class variable. So 'B' cannot be the right answer.

FR99Option: D
Oct 24, 2020

The Answer is definitely 'D. an instance variable'

BrodehOption: A
Mar 20, 2021

ANswer is A

TestPythOption: B
Jan 23, 2022

A Python class variable is shared by all object instances of a class. Class variables are declared when a class is being constructed. They are not defined inside any methods of a class. Because a class variable is shared by instances of a class, the Python class owns the variable. B IS CORRECT

macxszOption: D
May 3, 2022

D. an instance variable