Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
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
1 / 6
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