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

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

Related documents


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)

 Create and use your own objects (class data types)  Use String methods: length, equals, equalsIgnoreCase, concat, charAt, and compareTo.  Use ActionListener interface to implement event handling.  Traverse an array to perform some operation on each element of an array.  Write a driver class that inherits from JFrame.  Call instance and class methods from another class. Terms algorithm, arrays, array index, element of an array, length of an array, control structures, event driven programming, class definition, objects, instance variables, class variables, constructors, get/set methods, toString method, access keywords, private, protected, public, extends and implements keywords, interface, abstract class, information hiding, inheritance, composition, Object class, subclass, super class, derived class, child and parent class, concatenation, parameter, encapsulation