CIS 121 Test 1 Review: Java Arrays, Code, Classes, Objects, Accessibility, Constructors, G, Exams of Computer Science

This review sheet is for test 1 of cis 121, covering topics such as arrays, java code, classes and objects, accessibility, constructors, get/set methods, tostring method, inheritance and composition, applets, and programming concepts. Topics include array definitions, indexes, accessing elements, array traversing, array sizes, array declaration and initialization in java, instance and class variables, access modifiers, constructors, get/set methods, tostring method, inheritance, composition, and event-driven programming.

Typology: Exams

Pre 2010

Uploaded on 08/19/2009

koofers-user-kqh
koofers-user-kqh 🇺🇸

10 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CIS 121
Test 1
Review Sheet
Arrays:
Theory
oWhat is the definition of an array? Why do we use arrays?
oCan the size of an array change?
oWhen is the size of an array determined?
oWhat is needed to access a single element from an array?
oWhat is an index?
oWhat is an element of an array?
oWhat types of data can arrays hold?
oWhat does it mean to traverse through an array?
oWhat is the range of index values for a specific array?
Java Code
oHow are arrays declared in Java?
oWhat symbols are used to denote that a variable is an array?
oHow do you access a single element from an array?
oWhat control structure is generally used to visit each element in an array?
oIn Java, how can you retrieve the total number of elements that a particular
array can hold?
oHow are arrays passed as parameters?
oWhat shortcut can be used to fill an array if the values that should be in the
array are known during the coding of the program? (the shortcut
combines the declaration and initialization of the array into one line of
Java code)
Classes and objects:
Instance and class variables
oWhat is an instance variable?
oWhat is a class variable?
oWhat are the basic differences between the two?
oWhat keyword is used to distinguish between them in your Java code?
Accessibility
oWhat does it mean to have public accessibility?
oWhat does it mean to have private accessibility?
oWhat does it mean to have protected accessibility?
Constructors
oWhat is a constructor and what is it used for?
oHow are constructor headers different from regular method headers?
oHow do you call constructors from another class?
oWhat is the method signature of the default constructor that Java
automatically creates if you have not defined a constructor?
oHow do you call the parent class’ constructor from the child’s constructor?
Get/Set methods
pf3

Partial preview of the text

Download CIS 121 Test 1 Review: Java Arrays, Code, Classes, Objects, Accessibility, Constructors, G and more Exams Computer Science in PDF only on Docsity!

CIS 121

Test 1 Review Sheet Arrays:  Theory o What is the definition of an array? Why do we use arrays? o Can the size of an array change? o When is the size of an array determined? o What is needed to access a single element from an array? o What is an index? o What is an element of an array? o What types of data can arrays hold? o What does it mean to traverse through an array? o What is the range of index values for a specific array?  Java Code o How are arrays declared in Java? o What symbols are used to denote that a variable is an array? o How do you access a single element from an array? o What control structure is generally used to visit each element in an array? o In Java, how can you retrieve the total number of elements that a particular array can hold? o How are arrays passed as parameters? o What shortcut can be used to fill an array if the values that should be in the array are known during the coding of the program? (the shortcut combines the declaration and initialization of the array into one line of Java code) Classes and objects:  Instance and class variables o What is an instance variable? o What is a class variable? o What are the basic differences between the two? o What keyword is used to distinguish between them in your Java code?  Accessibility o What does it mean to have public accessibility? o What does it mean to have private accessibility? o What does it mean to have protected accessibility?  Constructors o What is a constructor and what is it used for? o How are constructor headers different from regular method headers? o How do you call constructors from another class? o What is the method signature of the default constructor that Java automatically creates if you have not defined a constructor? o How do you call the parent class’ constructor from the child’s constructor?  Get/Set methods

o What are get/set methods used for? o Why are they sometimes necessary? o What are some examples when you would want or need to use them?  toString method o What is the toString method used for? o When is the toString method automatically called? o What class do all Java classes inherit the toString method from? o What is the method header for the toString method?  Inheritance and composition o What is inheritance? o What keyword is generally used in the class header to denote inheritance? o Why is inheritance useful? (think about our applets) o If we do not explicitly extend a class, then our class will automatically inherit from which predefined Java class? o What is composition? o What do we mean by “is a” and “has a” relationships?  How are objects passed as parameters?  What is polymorphism?  Explain how can polymorphism be implemented with a set of classes and an array.  When does polymorphism occur? What do we mean by dynamic binding?  Be able to draw a class diagram showing inheritance. Be able to draw a class diagram showing the data and operations of a class. Applets  Use of init and paint methods. Graphics  Be able to use basic methods of the Graphics class: drawLine, drawString, drawRect, drawOval, fillRect, and fillOval. Event-driven programming  What are JLabel, JButton, JTextField?  What are JScrollPane and JTextArea?  What is ActionListener and ActionEvent?  What is a JFrame and a JApplet?  Explain steps needed to code an applet or JFrame which is event driven.  How is ActionListener different than a regular class in Java?  What methods belong to ActionListener?  Can a JFrame or JApplet be an ActionListener? Programming: Know how to…  Use relational and logical operators.  Use if statements, switch statements, for loops, while loops, and do-while loops.  Create, fill, and use arrays of any specified data type  Write methods for applications and class definitions (instance and class methods)