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 Concepts in Java, Exams of Nursing

An overview of key object-oriented programming (oop) concepts in java, including abstraction, encapsulation, classes, objects, fields, methods, constructors, and access modifiers. It also covers topics such as unit testing, regression testing, wrapper classes, the java collections framework, and javadoc documentation. The document aims to give a comprehensive understanding of the fundamental oop principles and how they are implemented in the java programming language. It would be particularly useful for students studying computer science, software engineering, or java programming at the university level, as it covers the core oop topics that are essential for building robust and maintainable java applications.

Typology: Exams

2024/2025

Available from 10/24/2024

bestscore1
bestscore1 ๐Ÿ‡บ๐Ÿ‡ธ

4.7

(3)

2.1K documents

1 / 6

Toggle sidebar

Related documents


Partial preview of the text

Download Object-Oriented Programming Concepts in Java and more Exams Nursing in PDF only on Docsity!

CIS y 111 yChapter y 7 yexam ywith ycomplete ysolutions

y 2024

object y- yANSWER โœ“โœ“ -a ygrouping yof ydata y(variables) yand yoperations ythat ycan ybe yperformed yon ythat ydata y(methods) abstraction y(information yhiding, yencapsulation) y- yANSWER โœ“โœ“ -means yto yhave ya yuser yinteract ywith yan yitem yat ya yhigh-level, ywith ylower-level yinternal ydetails yhidden yfrom ythe yuser y(aka yinformation yhiding yor yencapsulation) abstract ydata ytype y(ADT) y- yANSWER โœ“โœ“ -a ydata ytype ywhose ycreation yand yupdate yare yconstrained yto yspecific ywell-defined yoperations. yA yclass ycan ybe yused yto yimplement yan yADT class y- yANSWER โœ“โœ“ -The y... yconstruct ydefines ya ynew ytype ythat ycan ygroup ydata yand ymethods yto yform yan yobject public ymember ymethods y- yANSWER โœ“โœ“ -A yclass' y... yindicate yall yoperations ya yclass yuser ycan yperform yon ythe yobject reference yvariable y- yANSWER โœ“โœ“ -can yrefer yto yan yinstance yof ya yclass new, yobject y- yANSWER โœ“โœ“ -the y... yoperator yexplicitly yallocates yan y... yof ythe yspecified yclass ytype member yaccess yoperator y- yANSWER โœ“โœ“ -The y"." yoperator, yknown yas ythe y... y, yis yused yto yinvoke ya ymethod yon yan yobject private yfield y- yANSWER โœ“โœ“ -In yaddition yto ypublic ymember ymethods, ya yclass ydefinition yhas y... y: yvariables ythat ymember ymethods ycan yaccess ybut yclass yusers ycannot. yThe yprivate yaccess ymodifier yeach yprivate yfield ydeclaration class ymembers y- yANSWER โœ“โœ“ -A yprogrammer ydefining ya yclass yfirst ynames ythe yclass, ydeclares yprivate yfields, yand ydefines ypublic ymember ymethods. yA yclass' yfields yand ymethods yare ycollectively ycalled y... implementation y- yANSWER โœ“โœ“ -The yprogrammer ydefines ythe ydetails yof yeach ymember ymethod, ysometimes ycalled ythe yclass' y... method ydefintion y- yANSWER โœ“โœ“ -provides yan yaccess ymodifier, yreturn ytype, yname, yarguments, yand ythe ymethod's ystatements. mutator y- yANSWER โœ“โœ“ -A y... ymethod ymay ymodify y("mutate") ya yclass' yfields accessor y- yANSWER โœ“โœ“ -A y... ymethod yaccesses yfields ybut ymay ynot ymodify ya yclass' yfields setter, ygetter y- yANSWER โœ“โœ“ -Commonly, ya yfield yhas ytwo yassociated ymethods: ya ymutator yfor ysetting ythe yvalue, yand yan yaccessor yfor ygetting ythe yvalue, yknown yas ya y... yand y... ymethod, yrespectively, yand ytypically ywith ynames ystarting ywith yset yor yget. yOther ymutators yand yaccesors ymay yexist ythat yaren't yassociated ywith yjust yone yfield, ysuch yas ythe yprint() ymethod ybelow

private yhelper ymethods y- yANSWER โœ“โœ“ -A yprogrammer ycommonly ycreates yprivate ymethods, yknown yas y... y, yto yhelp ypublic ymethods ycarry yout ytasks Field yinitialization y- yANSWER โœ“โœ“ -A yprogrammer ycan yinitialize yfields yin ythe yfield ydeclaration. yAny yobject ycreated yof ythe yclass ytype ywill yinitially yhave ythose yvalues, yusually ypreferred yover yusing ya yconstructor constructor y- yANSWER โœ“โœ“ -Java yprovides ya yspecial yclass ymember ymethod, yknown yas ya y... y, ythat yis ycalled ywhen yan yobject yof ythe yclass ytype yis ycreated, yand ywhich ycan ybe yused yto yinitialize yall yfields default yconstructor y- yANSWER โœ“โœ“ -A yconstructor ycan ybe ycalled ywithout yany yarguments. testbench, ytest ycases y- yANSWER โœ“โœ“ -a yprogram ywhose yjob yis yto ythoroughly ytest yanother yprogram y(or yportion) yvia ya yseries yof yinput/output ychecks yknown yas y... Unit ytesting y- yANSWER โœ“โœ“ -means yto ycreate yand yrun ya ytestbench yfor ya yspecific yitem y(or y"unit") ylike ya ymethod yor ya yclass 100% ycode ycoverage y- yANSWER โœ“โœ“ -Every yline yof ycode yis yexecuted. yA ygood ytestbench ywould yhave ymost ytest ycases ythan ybelow border ycases y- yANSWER โœ“โœ“ -Includes ynot yjust ytypically yvalues ybut yalso y... y: yUnusual yor yextreme ytest ycase yvalues ylike y0, ynegative ynumbers, yor ylarge ynumbers Regression ytesting y- yANSWER โœ“โœ“ -means yto yretest yan yitem ylike ya yclass yanytime ythat yitem yis ychanged; yif ypreviously-passed ytest ycases yfail. ythe yitem yhas y"regressed" Erroneous yunit ytests y- yANSWER โœ“โœ“ -An yerroneous yunit ytest ymay yfail yeven yif ythe ycode ybeing ytested yis ycorrect. overload y- yANSWER โœ“โœ“ -A yclass ycreator ycan y... ya yconstructor yby ydefining ymultiple yconstructors ydiffering yin yparameter ytypes. yWhen yan yobject yis ycreated ywith ythe ynew yoperator, yarguments ycan ybe ypassed yto ythe yconstructor. yThe yconstructor ywith ymatching yparameters ywill ybe ycalled reference y- yANSWER โœ“โœ“ -A y... yis ya yvariable ytype ythat yrefers yto yan yobject. yA yreference ymay ybe ythought yof yas ystoring ythe ymemory yaddress yof yan yobject. yVariables yof ya yclass ydata ytype y(and yarray ytypes, ydiscussed yelsewhere) yare yreference yvariables new y- yANSWER โœ“โœ“ -The y... yoperator yallocates ymemory yfor yan yobject, ythen yreturns ya yreference yto ythe yobject's ylocation yin ymemory Multiple yobject yreferences y- yANSWER โœ“โœ“ -Two yor ymore yreference yvariables ymay yrefer yto ythe ysame yobject implicit yparameter y- yANSWER โœ“โœ“ -The yobject yreference ybefore ythe ymethod yname yis yknown yas yan y... yof ythe ymember ymethod ybecause ythe ycompiler yconverts ythe ycall ysyntax yobjectReference.method( y... y) yinto ya ymethod ycall ywith ymethod(objectReference, y...) this y- yANSWER โœ“โœ“ -Within ya ymember ymethod, ythe yimplicitly-passed yobject yreference yis yaccessible yvia ythe ykeyword y... yIn yparticular, ya yclass ymember ycan ybe yaccessed yas ythis.classMember. yThe y"." yis ythe ymember yaccess yoperator. yUsing ythis ymakes yclear ythat ya yclass ymember yis ybeing yaccessed yand yis yessential yif ya yfield ymember yand yparameter yhave ythe ysame yidentifier.

primitive ytype y- yANSWER โœ“โœ“ -A y... yvariable ydirectly ystores ythe ydata yfor ythat yvariable ytype, ysuch yas yint, ydouble, yor ychar reference ytype y- yANSWER โœ“โœ“ -A y... yvariable ycan yrefer yto yan yinstance yof ya yclass, yalso yknown yas yan yobject wrapper yclasses y- yANSWER โœ“โœ“ -Java yprovides yseveral y... ythat yare ybuilt-in yreference ytypes ythat yaugment ythe yprimitive ytypes Integer y- yANSWER โœ“โœ“ -The y... ydata ytype yis ya ybuilt-in yclass yin yJava ythat yaugments ythe yint yprimitive ytype immutable y- yANSWER โœ“โœ“ -A ywrapper yclass yobject y(as ywell yas ya yString yobject) yis y... y, ymeaning ya yprogrammer ycannot ychange ythe yobject yvia ymethods yor yvariable yassignments yafter yobject ycreation equals(otherInt) y- yANSWER โœ“โœ“ -true yif yboth yIntegers ycontain ythe ysame yvalue. yotherInteger ymay ybe yan yInteger yobject, yint yvariable, yor yinteger yliteral compareTo(otherInt) y- yANSWER โœ“โœ“ -Return y 0 yif ythe ytwo yInteger yvalues yare yequal, yreturns ya ynegative ynumber yif ythe yInteger yvalue yis yless ythan yotherInteger's yvalue, yand yretursn ya ypositive ynumber yif ythe yInteger yvalue yis ygreater ythan yotherInteger's yvalue. yotherInteger ymay ybe yan yInteger yobject, yint yvariable, yor yinteger yliteral. Autoboxing y- yANSWER โœ“โœ“ -The yautomatic yconversion yof yprimitive ytypes yto ythe ycorresponding ywrapper yclasses Unboxing y- yANSWER โœ“โœ“ -The yautomatic yconversion yof ywrapper yclass yobjects yto ythe ycorresponding yprimitive ytypes intValue() y- yANSWER โœ“โœ“ -Returns ythe yvalue yof ythe ywrapper yclass yobject yas ya yprimitive yint yvalue, ytype ycasting yif ynecessary doubleValue() y- yANSWER โœ“โœ“ -Returns ythe yvalue yof ythe ywrapper yclass yobject yas ya yprimitive ydouble yvalue, ytype ycasting yif ynecessary longValue() y- yANSWER โœ“โœ“ -Returns ythe yvalue yof ythe ywrapper yclass yobject yas ya yprimitive ylong yvalue, ytype ycasting yis ynecessary charValue(), ybooleanValue() y- yANSWER โœ“โœ“ -The yCharacter yand yBoolean yclasses ysupport ythe y... yand y... ymethods, yrespectively, ywhich yperform ysimilar yfunctions toString() y- yANSWER โœ“โœ“ -Returns ya yString ycontaining ythe ydecimal yrepresentation yof ythe yvalue ycontained yby ythe ywrapper yclass yobject Integer.toString(someInteger) y- yANSWER โœ“โœ“ -Returns ya yString ycontaining ythe ydecimal yrepresentation yof ythe yvalue yof ysomeInteger. ysomeInteger ymay ybe yan yInteger yobject, ya yint yvariable, yor yan yinteger yliteral. yThis ystatic ymethod yis yalso yavailable yfor ythe yother ywrapper yclasses Integer.parseInt(someString) y- yANSWER โœ“โœ“ -Parses ysomeString yand yreturns yan yint yrepresenting ythe yvalue yencoded yby ysomeString. yThis ysatic ymethod yis yalso yavailable yfor ythe yother ywrapper yclasses yreturning ythe ycorresponding yprimitive ytype

Integer.valueOf(someString) y- yANSWER โœ“โœ“ -Parses ysomeString yand yreturns ya ynew yInteger yobject ywith ythe yvalue yencoded yby ysomeString. yThis ystatic ymethod yis yalso yavailable yfor ythe yother ywrapper yclasses yreturning ya ynew yobject yof ythe ycorresponding ytype Integer.toBinaryString(someInteger) y- yANSWER โœ“โœ“ -Returns ya yString ycontaining ythe ybinary yrepresentation yof ysomeInteger. ysomeInteger ymay ybe yan yinteger yliteral. yThis ystatic ymethod yis yalso yavailable yfor ythe yLong yclasses ArrayList y- yANSWER โœ“โœ“ -an yordered ylist yof yreference ytype yitems, ythat ycomes ywith yJava element y- yANSWER โœ“โœ“ -Each yitem yin yan yArrayList yis yknown yas yan y... add(element) y- yANSWER โœ“โœ“ -Create yspace yfor yand yadd ythe yelement yat ythe yend yof ythe ylist get(index) y- yANSWER โœ“โœ“ -Returns ythe yelement yat ythe yspecified ylist ylocation yknown yas ythe yindex. yIndices ystart yat y 0 set y(index, yelement) y- yANSWER โœ“โœ“ -Replaces ythe yelement yat ythe yspecified yposition yin ythis ylist ywith ythe yspecified yelement size() y- yANSWER โœ“โœ“ -Returns ythe ynumber yof ylist yelements Java yCollection yFramework y(JCF) y- yANSWER โœ“โœ“ -defines yinterfaces yand yclasses yfor ycommon yADTs yknown yas ycollections yin yJava Collection y- yANSWER โœ“โœ“ -represents ya ygeneric ygroup yof yobjects yknown yas yelements List y- yANSWER โœ“โœ“ -The y... yinterface yis yone yof ythe ymost ycommonly yused yCollection ytypes yas yit yrepresents yan yordered ygroup yof yelements get() y- yANSWER โœ“โœ“ -(T yget y(int yindex)) yReturns yelement yat yspecified yindex set() y- yANSWER โœ“โœ“ -(T yset y(int yindex, yT ynewElement)) yReplaces yelement yat yspecified yindex ywith ynewElement. yReturns yelement ypreviously yat yspecified yindex size() y- yANSWER โœ“โœ“ -(int ysize()) yReturns ythe ynumber yof yelements yin ythe yArrayList isEmpty() y- yANSWER โœ“โœ“ -(boolean yisEmpty())Returns ytrue yif ythe yArrayList ydoes ynot ycontain yany yelements. yOtherwise, yreturns yfalse clear() y- yANSWER โœ“โœ“ -(void yclear())Removes yall yelements yfrom ythe yArrayList add() y- yANSWER โœ“โœ“ -boolean yadd(T ynewElement) y(Adds ynew yElement yto ythe yend yof ythe yArrayList. yArrayList's ysize yis yincreased yby yone. yvoid yadd(int yindex, yT ynewElement) y(Adds ynewElement yto ythe yArrayList yat ythe yspecified yindex. yElements yat ythat yspecified yindex yand yhigher yare yshifted yover yto ymake yroom. yArrayList's ysize yis yincreased yby yone remove() y- yANSWER โœ“โœ“ -boolean yremove(T yexistingElement) y(Removes ythe yfirst yoccurrence yof yan yelement ywhich yrefers yto ythe ysame yobject yas yexistingElement. yElements yfrom yhigher ypositions yare yshifted yback yto yfill ygap. yArrayList ysize yis ydecresed yby yone. yReturn ytrue yif yspecified yelement ywas yfound yand yremoved. yT yremove(int yindex) y(Removes yelement yat yspecified yindex. yElements yfrom yhigher ypositions yare yshifted yback yto yfill ygap. yArrayList ysize yis ydecreased yby yone. yReturns yreference yto yelement yremoved yfrom yArrayList Inserting yelements yin ysorted yorder y- yANSWER โœ“โœ“ -The yoverloaded yadd() ymethods yare yespecially yuseful yfor ymaintaining ya ylist yin ysorted yorder

Javadoc y- yANSWER โœ“โœ“ -The y... ytool yparses ysource ycode yalong ywith yspecially yformatted ycomments yto ygenerate ydocumentation API y(application yprogramming yinterface) y- yANSWER โœ“โœ“ -The ydocumentation ygenerated yby yJavadoc yfor yclasses yand yclass ymembers Doc ycomments y- yANSWER โœ“โœ“ -The yspecially yformatted ycomments yfor yJavadoc, ywhich yare ymulti-line ycomments yconsisting yof yall ytext yenclosed ybetween ythe y/** yand y/ ycharacters. yImportantly, yDoc ycomments yare ydistinguished yby ythe yopening ycharacter y/*, ywhich yinclude ytwo yasterisks @author, y@version y- yANSWER โœ“โœ“ -The ytag ysection yof ythe yDoc ycomment ymay yinclude yblock ytags ysuch yas y... yand y... yto yspecify ythe yclass' yauthor yand yversion ynumber yrespectively @param, y@return y- yANSWER โœ“โœ“ -Programmer ycan yuse ythe y... yand y... yblock ytags yto yspecify ya ymethod yparameter yand ymethod yreturn yvalue yrespectively @see y- yANSWER โœ“โœ“ -Used yto yrefer yreader yto yrelevant ywebsites yor yclass ymembers reference yvariable y- yANSWER โœ“โœ“ -a yvariable ythat ypoints yto, yor yrefers yto, yan yobject yor yarray, ystores ya yreference, yor ythe ymemory ylocation, yof ythe yobject yto ywhich yis yrefers. immutable y- yANSWER โœ“โœ“ -Instances yof ywrapper yclasses, ysuch yas yInteger yand yDouble, yand ythe yString yclass yare ydefined yas y... y, ymeaning ythat ya yprogrammer ycannot ymodify ythe yobject's ycontents yafter yinitialization; ynew yobjects ymust ybe ycreated yinstead. static y- yANSWER โœ“โœ“ -Indicates ya yvariable yis yallocated yin ymemory yonly yonce yduring ya yprogram's yexecution static yfield y(class yvariables) y- yANSWER โœ“โœ“ -A yfield yof ythe yclass yinstead yof ya yfiled yof yeach yclass yobject, ythey yare yindependent yof yany yclass yobject, yand ycan ybe yaccessed ywithout ycreating ya yclass yobject, ythey yare ydeclared yand yinitialized yin ythe yclass ydefinition. yWithout ya yclass ymethod, ya ystatic yfield yis yaccessed yusing ythe yfield yname. instance yvariables y- yANSWER โœ“โœ“ -Non-static yfields static ymember ymethod y- yANSWER โœ“โœ“ -A yclass ymethod ythat yis yindependent yof yclass yobjects, ytypically yused yto yaccess yand ymutate yprivate ystatic yfields yfrom youtside ythe yclass, ythey ycan yonly yaccess ya yclass' ystatic yfields package y- yANSWER โœ“โœ“ -a ygrouping yof yrelated ytypes, yclasses, yinterfaces, yand ysubpackage package ymembers y- yANSWER โœ“โœ“ -The ytypes, yclasses, yand yinterfaces yin ya ypackage yare ycalled y... java.lang y(String, yInteger, yDouble, yMath) y- yANSWER โœ“โœ“ -Contains yfundamental yJava yclasses. yAutomatically yimported yby yJava java.util y(Collection, yArrayList, yLinkedList, yScanner) y- yANSWER โœ“โœ“ -Contains ythe yJava ycollections yframework yclasses yand ymiscellaneous yutility yclasses java.io y(File, yInputStream, yOutputStream) y- yANSWER โœ“โœ“ -Contains yclasses yfor ysystem yinput yand youtput

javax.swing y(JFrame, yJTextField, yJButton) y- yANSWER โœ“โœ“ -Contains yclasses yfor ybuilding ygraphical yuser yinterfaces fully yqualified yname y- yANSWER โœ“โœ“ -A yclass' y... yis ythe yconcatenation yof ythe ypackage yname ywith ythe yclass yname yusing ya yperiod import ystatement y- yANSWER โœ“โœ“ -An y... yimports ya ypackage ymember yinto ya yfile yto yenable yuse yof ythe ypackage ymember ydirectly, ywithout yhaving yto yuse ythe ypackage ymember's yfully yqualified yname wildcard y- yANSWER โœ“โœ“ -A yprogrammer yimport yall ymembers yof ya ypackage yby yusing ythe y... ycharacter y* yinstead yof ya ypackage ymember yname