C a; C b; C e; int c;

Size: px
Start display at page:

Download "C a; C b; C e; int c;"

Transcription

1 CS1130 section 3, Spring 2012: About the Test 1 Purpose of test The purpose of this test is to check your knowledge of OO as implemented in Java. There is nothing innovative, no deep problem solving, no writing of algorithms. Timing The test will be given for a first time on Friday, 13 April, at 2:30 and 3:35. We expect everyone to take it then, and we hope that the majority of you will pass. Anyone who knows the material will finish it in less than 1/2 hour. Rest of handout Below, we talk about the questions on the exam. For each (except the last), we give some example questions (one with answer) or give an answer along with notes about it. After that is a summary of major definitions and concepts. Questions on the exam There will be four questions, as shown below. The first three are the most important, because each uses important, basic OO Concepts and principles. You are expected to get these right, expect perhaps for minor mistakes. After the list, we give sample questions with answers and discussion. 1. Executing a sequence of assignments that include new-expressions. 2. Writing equals functions 3. Writing constructors. 4. Definitions, principles. Question 1. Executing sequences of assignments On Assignment A3, you showed that you knew how to evaluate a new-expression. If you can also execute an assignment statement, if you know how to draw an object, and if you are careful, this question is easy. Q1A. Example. This question deals with classes B and C: public class C { private int x; public C(int n) { x= n; public int mult() {return 4 * bv; public class B extends C { private int y; public B(int n) { super(n+2); y= n; public int mult() { return super.mult()/2; public int altm() { return super.mult(); public static int add(a a, A b) {return a.mult() + b.mult(); (a) Below are four declarations of variables. Draw those variables. C a; C b; C e; int c; (b)execute the following sequence of statements, drawing any objects that are created in the space to the right below and storing values as needed in the variables drawn in step (a). When storing a value in a variable, cross off the old value; don t erase it. There is no need to draw frames for method calls but do it if it helps you (it will). Answer a a5 a5 x 3 a= new C(3); b= new B(2); e= b; c= b.mult(); b a6 C() mult() C e a6 c 6 a6 y x 4 C() mult() 2 C B B() mult() altm() Notes 1. Two objects are drawn because only evaluation of a new-expression creates/draws a new object. 2. You must be able to draw objects of a subclass properly, as have done. 3. Do not use the name of a variable to which an object is assigned as the name on the tab of an object. If you used a or b or c for the name on the tab of an object, we would assume that you do not understand what you are doing. 4. Do not draw variable or an object several times to show how it changes. Draw the variable or object once, and then change it if necessary. Q1B. Example. Consider this class: /** An instance represents a Student*/ public class Student { private int id; // the student s ID page 1

2 CS1130 section 3, Spring 2012: About the Test 2 private int birthyear; // the student s year of birth /** Constructor: a student with id d and birth year y */ public Student(int d, int y) { id= d; birthyear= y; Below are two initializing declarations and an assignment. Student p1= new Student(356, 1987); Student p2= new Student(123, 1988); p1= p2; (a) Draw the variables that are declared in the statements given above. (b) Using the variables you drew in part (a), execute the sequence of three statements, drawing any objects created during execution and assigning to variables as required by execution. Q1C. Example. Consider this class: /** An instance represents an Employee*/ public class Employee { private int ssn; // the employee s ssn private int salary; //annual salary /** Constructor: an employee with ssn n and salary s */ public Employee(int n, int s) { ssn= n; salary= s; Below are two initializing declarations and an assignment. Employee e1= new Employee(123, 50000); Employee e2= new Employee(456, 45000); e1= e2; (a) Draw the variables that are declared in the statements given above. (b) Using the variables you drew in part (a), execute the sequence of three statements, drawing any objects created during execution and assigning to variables as required by execution. Q1D. Example. Consider these classes: /** An instance maintains info about a celebrity */ public class Celeb { private String name; // celebrity's name // celebrity's no. in the list of celebrities */ private int celebnum; // total number of celebrities private static int numcelebs= 0; /** Constructor: a celebrity with name n. */ public Celeb(String n) { name= n; celebnum= numcelebs; numcelebs= numcelebs + 1; /** An instance maintains info about an athlete*/ public class Ath extends Celeb { private String sport; // The athlete's sport private int win; // # of wins private int loss; // # of losses private double salary; // The athlete's salary /** Constructor: athlete with name n, playing sport sport. Has no wins, losses, or salary. */ public Ath(String n, String sport){ super(n); this.sport= sport; Draw the static components of Celeb (do not draw file drawers) you do not have to draw the method body. Next, evaluate first the leftmost new-expression below and then the rightmost one, assuming that these are the first new-expressions evaluated. Under each newexpression, draw the object that results from evaluation of that new-expression; above each new-expression, write its value. Include the partition for class Object, and put in two methods that you know are declared in Object. Be sure to fill in the values of fields correctly, based on the specifications of the methods in the classes. new Celebrity("ARod") new Athlete("BRod", "BB", 100) Question 2. Writing equals functions The purpose of this question is to 1. Test your ability to read and implement a spec, 2. Know how to use the instanceof operator, 3. Know when and how to cast, 4. Be able to declare a local variable of a method, 5. Understand where a private variable cannot be used, 6. Perhaps be able to call the equals function in a superclass if necessary. This is all very straightforward. Equals functions almost always have three parts: Test whether the parameter is of the right class, cast the parameter to the proper class so that it fields can be referenced, return the result using an expression that tests equality of the appropriate fields. Q2A. Example. Consider this class: /** An instance is a rational number */ public class Rational { /** Class invariant: the rational number is num / den page 2

3 CS1130 section 3, Spring 2012: About the Test 3 Restrictions on fields: 1. den > 0 2. if num = 0, then den = 1 3. num / den is in lowest possible terms. E.g. 20/8 is stored as 5/2. */ private int num; private int den;... methods are not shown... Write the body of function equals (we do this one for you): /** = "r is of class Rational and has the same value as this Rational number. */ public boolean equals(object r) { if (!(r instanceof Rational)) return false; Rational ob= (Rational) r; return num == ob.num && den == ob.den; Q2B. Example. Consider these classes: /** An instance maintains info about an athlete*/ public class Ath extends Celeb { private String sport; // The athlete's sport private int win; // # of wins private int loss; // # of losses private double salary; // The athlete's salary... methods are not shown... /** Instance maintains info about a celebrity */ public class Celeb { private String name; // celebrity's name /* celebrity's no. in the list of celebrities */ private int celebnum; // total number of celebrities private static int numcelebs= 0; /** = ob is a celebrity and has the same fields as this Celeb object */ public boolean equals(object ob) { other methods not shown... Complete the body function equals, below, to go in class Ath. This one has a trickiness to it. How are you going to check that the names are the same when field name is private and there is no getter method for the name field? Answer, look in class Celeb and see whether anything can help. /** = "a is of class Ath and has the same name and sport as this Ath. */ public boolean equals(object a) { Q2C. Example. Consider this class: /** Instance maintains info about a president */ public class Pres { private int syear; // Was president in years private int eyear; // syear..eyear private String name; // name of president private Pres prev; // the previous president // (null if none)... methods not shown... Complete the body of the following function equals, to be written in class Pres. /** = p is a Pres and has the same values in its fields as this Pres object */ public boolean equals(object p) { Question 3. Writing constructors The purpose of this question is always to check your ability to (1) write constructors, including calls on other constructors, (2) use this and super, (3) understand the use of preconditions, (4) know where private fields cannot be used, and (5) deal appropriately with a static variable. Below, we give classes with constructors. Within the second class, have remarks such as NOTE 1 ; see the notes after the class. /** An instance maintains info about a celebrity */ public class Celebrity { private String name; // celebrity's name private int celebnum;// celebrity's no. in the // list of celebrities it is the number of // celebrities when this one became a celebrity private static int numcelebs= 0; // total # of celebrities /** Constructor: a celebrity with name n. */ public Celebrity(String n) { name= n; celebnum= numcelebs; numcelebs= numcelebs + 1; /** = this celebrity's number */ public int getcelebnum() {... /** = total number of celebrities */ public static int getnumcelebs() {... /** = String rep of the celebrity, giving its name. */ public String tostring() {... /** Instance: info about an athlete*/ public class Ath extends Celeb { private String sport; // athlete's sport private int win; // # of wins private int loss; // # of losses private double salary; // athlete's salary page 3

4 CS1130 section 3, Spring 2012: About the Test 4 /** Constructor: athlete with name n, playing sport sport. Has no wins, losses, or salary. */ public Athlete(String n, String sport){ super(n); NOTE 1 this.sport= sport; NOTE 2, NOTE 3 /** Constructor: athlete with name n, playing sport s, with salary p. No wins or losses. */ public Athlete(String n, String s, double p){ this(n, s); NOTE 4, NOTE 5 salary= p; /** = String representation of the celebrity in the following format: <string produced by tostring in superclass> "#" <celebrity s number> " " <sport> e.g. "Celebrity Tom.#5 Baseball" */ public String tostring(){ return super.tostring() + NOTE 6 "#" + getcelebnum() + " " + sport; NOTES: 1. Principle: fill in superclass fields first. Best way: call a constructor in the superclass. Always try this first. You have to find the superclass constructor and read its specification. In fact, the first statement of a constructor body must be a call on another constructor; if not, Java inserts super();. 2. this. is needed because otherwise sport refers to parameter. Remember: this evaluates to name of object in which is occurs. 3. Assignments to other fields are not necessary in this case because of defaults (default for int is 0, etc.). 4. Principle: Save time and energy (programming and debugging) and make a program look shorter and simpler by calling already written methods instead of duplicating code. 5. Note how this(...) calls another constructor in this class, while super(...) calls another constructor in the superclass. 6. The question itself cries out for this call on the superclass tostring. It is not always that clear, and sometimes one must look around to see what to do. This is another example of the Principle stated in point 4. Concepts and Definitions Know the following terms, backward and forward. Wishy-washy definitions will not get much credit. Learn these not by reading but by practicing writing them down, or have a friend ask you these and repeat them out loud. You should be able to write simple programs that use the concepts defined below, and you should be able to draw objects of classes and frames for calls. Abstract classes and methods. Know how to make a class abstract and the purpose: so that it cannot be instantiated. Know how to make a method abstract and the purpose: so that it must be overridden in any nonabstract subclass. See pp Access modifier: private or public. A public component can be access from anywhere, a private one only in the class in which it is declared. Generally fields are private. Apparent and real types, casting, operator instanceof, and function equals. Study pp Know how to write a function equals. See the discussion below under equals. Argument: An expression that occurs within the parentheses (and separated by commas) of a method call. Arrays: WILL NOT BE ON THE TEST. Casting. Just as one can cast an int i to another type, using, e.g. (byte) i or (double) i, one can cast a variable of some class-type to a superclass or subclass. Look in PLive to see about this. See Section 4.2. Calling one constructor from another. Principle: initialize superclass fields before subclass fields. Java helps enforce this: In a constructor, the first statement must be a call on another constructor in the same class (use this instead of the class-name) or a call on a constructor of the superclass (use super instead of the class-name). If not, Java inserts the call super(). Classes. What is a class? Class definition. Instance (folder, or object) of a class. The name of a folder. Components: fields and methods. Static and non-static components of a class (where do they go?). The newexpression and what it is used for. What this means: in a method, this evaluates to the object in which the method occurs. What super means: in a method, super evaluates to the object in which the method occurs but only starting at the partition above the one in which super occurs. See entry new-expression below. equals(object ob). Suppose this instance function is declared in class C. This boolean function returns the page 4

5 CS1130 section 3, Spring 2012: About the Test 5 value of "ob is the name of an object of class C and is equal to this object". The meaning of "equal to this object" depends on the writer of the method and should be specified in the comment before the function. In class Object, it means "this object and ob are the same object". Thus, for the equals defined in Object, b.equals(d) and b == d have the same value (except in the case b = null!). Usually, "equal to this object" means "the fields of this object and object ob are equal". See p Method equals on p. 155 is written incorrectly, because e has to be cast to Employee in order to reference the fields. It should be: /** = "e is an Employee, with the same fields as this Employee" */ public boolean equals(object e) { if (!(e instanceof Employee)) return false; Employee ec= (Employee) e; return name.equals(ec.name) && start == ec.start && salary == ec.salary; Exception handling. WILL NOT BE ON THE TEST! (1)Every throwable object is a subclass of Throwable. (2)The throw statement: throw object; (3)What happens when an object is thrown. (4)How the try-statement is executed. try {... catch (<throwable class> e) {... Expressions with types int, double, boolean, char (their ranges and basic operations). Casting between types. Narrower type, wider type. Know how to use a conditional expression (<bool exp>? exp1 : exp2) Folder. We assume you can draw a folder, or object or instance of a class. For subclasses, remember that the folder has more than one partition. Put in the partition for class Object, if asked. Frame for a method call. The frame for a method call contains: (1) the name of the method and the program counter, in a box in the upper left, (2) the scope box (see below), (3) the local variables of the method, (4) the parameters of the method. Inheriting methods and fields. A subclass inherits all the components (fields and methods) of its superclass. Inside-out and bottom-up rules. Used in determining which declaration a variable reference or method call refers to. Look them up in the text. instanceof. ob instanceof C has the value of "object ob is an instance of class C". p Method call execution or evaluation: (1)Draw a frame for the call. (2)Assign the (values of) the arguments to the parameters. (3)Execute the method body. When a name is used, look for it in the frame for the call. If it is not there, look in the place given by the scope box. (4)Erase the frame for the call. Methods, kinds of: procedure, function, constructor: Procedure definition: has keyword void before the procedure name. A procedure call is a statement. Function definition: has the result type in place of void. A function call is an expression, whose value is the value returned by the function. Constructor definition: has neither void nor a type; its name is the same as the name of the class in which it appears. The purpose of the constructor is to initialize the fields of a newly created folder. New-expression. An expression of the form new <class-name> (<arguments>) It is evaluated as follows: (1)create a new object of class class-name and put it in <class-name>'s file drawer. (2)Execute the constructor call <class-name> (<arguments>); the method being called appears in the newly created object. (3)Yield as the result of the new-expression the name of the object created in step (1). Object. Every class that does not explicitly extend another subclass automatically extends class Object. Class Object has at least two instance methods: tostring and equals. Overriding a method. In a subclass, one can redefine a method that was defined in a superclass. This is called overriding the method. In general, the overriding method is called. To call the overridden method m (say) of the superclass, use the notation super.m(...) this can only be done in methods of the subclass. Real and apparent class. A variable x declared using, page 5

6 CS1130 section 3, Spring 2012: About the Test 6 say, SomeClass x; has apparent class SomeClass. The apparent class is used in determining whether a reference to a field or method is syntactically legal. One can write x.m(...), for example, if and only if method m is declared in or inherited by class SomeClass. The real class of x is the class of an object that is in x. It could be a subclass. If x.m(...) is legal, then it calls the method that is accessible in the real class, not the apparent class. pp Scope box for a call contains: For a static method: the name of the class in which the method appears. For an instance method: the name of the object in which the instance appears. String methods. Know about the basic String functions length(), charat(k) and about catenation +. We will specify any others that you need. Subclasses. How to define a subclass. Inheritance and overriding. Constructors in a subclass. If you don t put in a constructor, Java puts this one in: public <class-name>(){. The first statement must be a call super( ); on a constructor of the superclass or a call this( ) on another constructor in this class. If there is none, super(); is used. Be able to draw an object of a class or subclass, given the class definition. Type. A set of values together with operations on them. Know about primitive types int, double, boolean, char. Variable: a name with associated value OR a named box that can contain a value of some type or class. For type int, the value is an integer. For a class, it is the name of (or reference to) an instance of the class the name that appears on the tab of the object. A variable declaration has the basic syntax: type variable-name ;. Its purpose is to indicate that a variable of the given type is to be used in the program. Four kinds of variable: local variable, parameter, instance variable (or field), static variable (or class variable). 1. A local variable is declared in the body of a method. It is drawn in a frame for a call on the method when the frame is created. Its scope is from its declaration to the end of the block in which it occurs. 2. A parameter is declared within the parentheses of a method header. The variable is drawn in a frame for a call on the method when the frame is created. Its scope is the method body. 3. An instance variable is declared in a class without modifier static. An instance variable is drawn in every folder of the class when the instance is created. 4. A static variable is declared in a class with modifier static. A static variable is placed in the file drawer for the class in which it is declared when program execution starts. Vector. Be able to use class Vector. On any question about Vector, we will specify any methods of class Vector that you need to answer the question you don't have to memorize them. Sec Wrapper class. With each primitive type (e.g. int) there is an associated wrapper class (e.g. Integer). Chap. 5. The wrapper class serves two purposes: (1)wrap or contain one value of the primitive type, so the primitive-type value can be treated as an object. (2)Contain some useful methods for operating on values of the primitive type. page 6

CS100J, Fall 2003 Preparing for Prelim 1: Monday, 29 Sept., 7:30 9:00PM

CS100J, Fall 2003 Preparing for Prelim 1: Monday, 29 Sept., 7:30 9:00PM CS100J, Fall 2003 Preparing for Prelim 1: Monday, 29 Sept., 7:30 9:00PM This handout explains what you have to know for the first prelim. Terms and their meaning Below, we summarize the terms you should

More information

Contents. I. Classes, Superclasses, and Subclasses. Topic 04 - Inheritance

Contents. I. Classes, Superclasses, and Subclasses. Topic 04 - Inheritance Contents Topic 04 - Inheritance I. Classes, Superclasses, and Subclasses - Inheritance Hierarchies Controlling Access to Members (public, no modifier, private, protected) Calling constructors of superclass

More information

PREPARING FOR THE FINAL EXAM

PREPARING FOR THE FINAL EXAM PREPARING FOR THE FINAL EXAM CS 1110: FALL 2017 This handout explains what you have to know for the final exam. Most of the exam will include topics from the previous two prelims. We have uploaded the

More information

Prelim 1 SOLUTION. CS 2110, September 29, 2016, 7:30 PM Total Question Name Loop invariants. Recursion OO Short answer

Prelim 1 SOLUTION. CS 2110, September 29, 2016, 7:30 PM Total Question Name Loop invariants. Recursion OO Short answer Prelim 1 SOLUTION CS 2110, September 29, 2016, 7:30 PM 0 1 2 3 4 5 Total Question Name Loop invariants Recursion OO Short answer Exception handling Max 1 15 15 25 34 10 100 Score Grader 0. Name (1 point)

More information

CS/ENGRD 2110 SPRING 2018

CS/ENGRD 2110 SPRING 2018 1 The fattest knight at King Arthur's round table was Sir Cumference. He acquired his size from too much pi. CS/ENGRD 2110 SPRING 2018 Lecture 6: Consequence of type, casting; function equals http://courses.cs.cornell.edu/cs2110

More information

Prelim 1, Solution. CS 2110, 13 March 2018, 7:30 PM Total Question Name Short answer

Prelim 1, Solution. CS 2110, 13 March 2018, 7:30 PM Total Question Name Short answer Prelim 1, Solution CS 2110, 13 March 2018, 7:30 PM 1 2 3 4 5 6 Total Question Name Short answer Exception handling Recursion OO Loop invariants Max 1 30 11 14 30 14 100 Score Grader The exam is closed

More information

Introduction to Programming Using Java (98-388)

Introduction to Programming Using Java (98-388) Introduction to Programming Using Java (98-388) Understand Java fundamentals Describe the use of main in a Java application Signature of main, why it is static; how to consume an instance of your own class;

More information

INHERITANCE. Spring 2019

INHERITANCE. Spring 2019 INHERITANCE Spring 2019 INHERITANCE BASICS Inheritance is a technique that allows one class to be derived from another A derived class inherits all of the data and methods from the original class Suppose

More information

CS-202 Introduction to Object Oriented Programming

CS-202 Introduction to Object Oriented Programming CS-202 Introduction to Object Oriented Programming California State University, Los Angeles Computer Science Department Lecture III Inheritance and Polymorphism Introduction to Inheritance Introduction

More information

Prelim 1. CS 2110, 13 March 2018, 7:30 PM Total Question Name Short answer

Prelim 1. CS 2110, 13 March 2018, 7:30 PM Total Question Name Short answer Prelim 1 CS 2110, 13 March 2018, 7:30 PM 1 2 3 4 5 6 Total Question Name Short answer Exception handling Recursion OO Loop invariants Max 1 30 11 14 30 14 100 Score Grader The exam is closed book and closed

More information

AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS

AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS PAUL L. BAILEY Abstract. This documents amalgamates various descriptions found on the internet, mostly from Oracle or Wikipedia. Very little of this

More information

Inheritance. Lecture 11 COP 3252 Summer May 25, 2017

Inheritance. Lecture 11 COP 3252 Summer May 25, 2017 Inheritance Lecture 11 COP 3252 Summer 2017 May 25, 2017 Subclasses and Superclasses Inheritance is a technique that allows one class to be derived from another. A derived class inherits all of the data

More information

COP 3330 Final Exam Review

COP 3330 Final Exam Review COP 3330 Final Exam Review I. The Basics (Chapters 2, 5, 6) a. comments b. identifiers, reserved words c. white space d. compilers vs. interpreters e. syntax, semantics f. errors i. syntax ii. run-time

More information

CS/ENGRD 2110 FALL Lecture 6: Consequence of type, casting; function equals

CS/ENGRD 2110 FALL Lecture 6: Consequence of type, casting; function equals 1 CS/ENGRD 2110 FALL 2017 Lecture 6: Consequence of type, casting; function equals http://courses.cs.cornell.edu/cs2110 Overview ref in JavaHyperText 2 Quick look at arrays array Casting among classes

More information

CMSC 132: Object-Oriented Programming II

CMSC 132: Object-Oriented Programming II CMSC 132: Object-Oriented Programming II Java Support for OOP Department of Computer Science University of Maryland, College Park Object Oriented Programming (OOP) OO Principles Abstraction Encapsulation

More information

CS/ENGRD 2110 FALL Lecture 6: Consequence of type, casting; function equals

CS/ENGRD 2110 FALL Lecture 6: Consequence of type, casting; function equals CS/ENGRD 2110 FALL 2018 Lecture 6: Consequence of type, casting; function equals http://courses.cs.cornell.edu/cs2110 Overview references in 2 Quick look at arrays: array Casting among classes cast, object-casting

More information

Java Object Oriented Design. CSC207 Fall 2014

Java Object Oriented Design. CSC207 Fall 2014 Java Object Oriented Design CSC207 Fall 2014 Design Problem Design an application where the user can draw different shapes Lines Circles Rectangles Just high level design, don t write any detailed code

More information

Super-Classes and sub-classes

Super-Classes and sub-classes Super-Classes and sub-classes Subclasses. Overriding Methods Subclass Constructors Inheritance Hierarchies Polymorphism Casting 1 Subclasses: Often you want to write a class that is a special case of an

More information

Prelim 1. Solution. CS 2110, 14 March 2017, 5:30 PM Total Question Name Short answer

Prelim 1. Solution. CS 2110, 14 March 2017, 5:30 PM Total Question Name Short answer Prelim 1. Solution CS 2110, 14 March 2017, 5:30 PM 1 2 3 4 5 Total Question Name Short answer OO Recursion Loop invariants Max 1 36 33 15 15 100 Score Grader 1. Name (1 point) Write your name and NetID

More information

PREPARING FOR PRELIM 2

PREPARING FOR PRELIM 2 PREPARING FOR PRELIM 2 CS 1110: FALL 2012 This handout explains what you have to know for the second prelim. There will be a review session with detailed examples to help you study. To prepare for the

More information

PREPARING FOR THE FINAL EXAM

PREPARING FOR THE FINAL EXAM PREPARING FOR THE FINAL EXAM CS 1110: FALL 2012 This handout explains what you have to know for the final exam. Most of the exam will include topics from the previous two prelims. We have uploaded the

More information

Brief Summary of Java

Brief Summary of Java Brief Summary of Java Java programs are compiled into an intermediate format, known as bytecode, and then run through an interpreter that executes in a Java Virtual Machine (JVM). The basic syntax of Java

More information

Prelim 1. CS 2110, 13 March 2018, 5:30 PM Total Question Name Short answer

Prelim 1. CS 2110, 13 March 2018, 5:30 PM Total Question Name Short answer Prelim 1 CS 2110, 13 March 2018, 5:30 PM 1 2 3 4 5 6 Total Question Name Short answer Exception handling Recursion OO Loop invariants Max 1 30 11 14 30 14 100 Score Grader The exam is closed book and closed

More information

Chapter 6 Introduction to Defining Classes

Chapter 6 Introduction to Defining Classes Introduction to Defining Classes Fundamentals of Java: AP Computer Science Essentials, 4th Edition 1 Objectives Design and implement a simple class from user requirements. Organize a program in terms of

More information

Objects and Iterators

Objects and Iterators Objects and Iterators Can We Have Data Structures With Generic Types? What s in a Bag? All our implementations of collections so far allowed for one data type for the entire collection To accommodate a

More information

Name Return type Argument list. Then the new method is said to override the old one. So, what is the objective of subclass?

Name Return type Argument list. Then the new method is said to override the old one. So, what is the objective of subclass? 1. Overriding Methods A subclass can modify behavior inherited from a parent class. A subclass can create a method with different functionality than the parent s method but with the same: Name Return type

More information

CISC 3115 Modern Programming Techniques Spring 2018 Section TY3 Exam 2 Solutions

CISC 3115 Modern Programming Techniques Spring 2018 Section TY3 Exam 2 Solutions Name CISC 3115 Modern Programming Techniques Spring 2018 Section TY3 Exam 2 Solutions 1. a. (25 points) A rational number is a number that can be represented by a pair of integers a numerator and a denominator.

More information

Declarations and Access Control SCJP tips

Declarations and Access Control  SCJP tips Declarations and Access Control www.techfaq360.com SCJP tips Write code that declares, constructs, and initializes arrays of any base type using any of the permitted forms both for declaration and for

More information

Advanced Programming - JAVA Lecture 4 OOP Concepts in JAVA PART II

Advanced Programming - JAVA Lecture 4 OOP Concepts in JAVA PART II Advanced Programming - JAVA Lecture 4 OOP Concepts in JAVA PART II Mahmoud El-Gayyar elgayyar@ci.suez.edu.eg Ad hoc-polymorphism Outline Method overloading Sub-type Polymorphism Method overriding Dynamic

More information

CS-140 Fall 2017 Test 2 Version A Nov. 29, 2017

CS-140 Fall 2017 Test 2 Version A Nov. 29, 2017 CS-140 Fall 2017 Test 2 Version A Nov. 29, 2017 Name: 1. (10 points) For the following, Check T if the statement is true, the F if the statement is false. (a) T F : An interface defines the list of fields

More information

Prelim 1. CS 2110, September 29, 2016, 7:30 PM Total Question Name Loop invariants

Prelim 1. CS 2110, September 29, 2016, 7:30 PM Total Question Name Loop invariants Prelim 1 CS 2110, September 29, 2016, 7:30 PM 0 1 2 3 4 5 Total Question Name Loop invariants Recursion OO Short answer Exception handling Max 1 15 15 25 34 10 100 Score Grader The exam is closed book

More information

Prelim 1. Solution. CS 2110, 14 March 2017, 7:30 PM Total Question Name Short answer

Prelim 1. Solution. CS 2110, 14 March 2017, 7:30 PM Total Question Name Short answer Prelim 1. Solution CS 2110, 14 March 2017, 7:30 PM 1 2 3 4 5 Total Question Name Short answer OO Recursion Loop invariants Max 1 36 33 15 15 100 Score Grader 1. Name (1 point) Write your name and NetID

More information

Rules and syntax for inheritance. The boring stuff

Rules and syntax for inheritance. The boring stuff Rules and syntax for inheritance The boring stuff The compiler adds a call to super() Unless you explicitly call the constructor of the superclass, using super(), the compiler will add such a call for

More information

Inheritance (Part 5) Odds and ends

Inheritance (Part 5) Odds and ends Inheritance (Part 5) Odds and ends 1 Static Methods and Inheritance there is a significant difference between calling a static method and calling a non-static method when dealing with inheritance there

More information

CMSC131. Inheritance. Object. When we talked about Object, I mentioned that all Java classes are "built" on top of that.

CMSC131. Inheritance. Object. When we talked about Object, I mentioned that all Java classes are built on top of that. CMSC131 Inheritance Object When we talked about Object, I mentioned that all Java classes are "built" on top of that. This came up when talking about the Java standard equals operator: boolean equals(object

More information

1 Inheritance (8 minutes, 9 points)

1 Inheritance (8 minutes, 9 points) Name: Career Account ID: Recitation#: 1 CS180 Spring 2011 Exam 2, 6 April, 2011 Prof. Chris Clifton Turn Off Your Cell Phone. Use of any electronic device during the test is prohibited. Time will be tight.

More information

Points To Remember for SCJP

Points To Remember for SCJP Points To Remember for SCJP www.techfaq360.com The datatype in a switch statement must be convertible to int, i.e., only byte, short, char and int can be used in a switch statement, and the range of the

More information

CS260 Intro to Java & Android 03.Java Language Basics

CS260 Intro to Java & Android 03.Java Language Basics 03.Java Language Basics http://www.tutorialspoint.com/java/index.htm CS260 - Intro to Java & Android 1 What is the distinction between fields and variables? Java has the following kinds of variables: Instance

More information

Operators and Expressions

Operators and Expressions Operators and Expressions Conversions. Widening and Narrowing Primitive Conversions Widening and Narrowing Reference Conversions Conversions up the type hierarchy are called widening reference conversions

More information

CS/ENGRD 2110 SPRING Lecture 7: Interfaces and Abstract Classes

CS/ENGRD 2110 SPRING Lecture 7: Interfaces and Abstract Classes CS/ENGRD 2110 SPRING 2019 Lecture 7: Interfaces and Abstract Classes http://courses.cs.cornell.edu/cs2110 1 Announcements 2 A2 is due Thursday night (14 February) Go back to Lecture 6 & discuss method

More information

CS/ENGRD 2110 SPRING Lecture 2: Objects and classes in Java

CS/ENGRD 2110 SPRING Lecture 2: Objects and classes in Java 1 CS/ENGRD 2110 SPRING 2018 Lecture 2: Objects and classes in Java http://courses.cs.cornell.edu/cs2110 Homework HW1 2 The answers you handed in at the end of lecture 1 showed mass confusion! Perhaps 80%

More information

AP CS Unit 6: Inheritance Notes

AP CS Unit 6: Inheritance Notes AP CS Unit 6: Inheritance Notes Inheritance is an important feature of object-oriented languages. It allows the designer to create a new class based on another class. The new class inherits everything

More information

Weiss Chapter 1 terminology (parenthesized numbers are page numbers)

Weiss Chapter 1 terminology (parenthesized numbers are page numbers) Weiss Chapter 1 terminology (parenthesized numbers are page numbers) assignment operators In Java, used to alter the value of a variable. These operators include =, +=, -=, *=, and /=. (9) autoincrement

More information

CO Java SE 8: Fundamentals

CO Java SE 8: Fundamentals CO-83527 Java SE 8: Fundamentals Summary Duration 5 Days Audience Application Developer, Developer, Project Manager, Systems Administrator, Technical Administrator, Technical Consultant and Web Administrator

More information

Logistics. Final Exam on Friday at 3pm in CHEM 102

Logistics. Final Exam on Friday at 3pm in CHEM 102 Java Review Logistics Final Exam on Friday at 3pm in CHEM 102 What is a class? A class is primarily a description of objects, or instances, of that class A class contains one or more constructors to create

More information

Lecture 10. Overriding & Casting About

Lecture 10. Overriding & Casting About Lecture 10 Overriding & Casting About Announcements for This Lecture Readings Sections 4.2, 4.3 Prelim, March 8 th 7:30-9:30 Material up to next Tuesday Sample prelims from past years on course web page

More information

CS111: PROGRAMMING LANGUAGE II

CS111: PROGRAMMING LANGUAGE II 1 CS111: PROGRAMMING LANGUAGE II Computer Science Department Lecture 8(a): Abstract Classes Lecture Contents 2 Abstract base classes Concrete classes Dr. Amal Khalifa, 2014 Abstract Classes and Methods

More information

Polymorphism. return a.doublevalue() + b.doublevalue();

Polymorphism. return a.doublevalue() + b.doublevalue(); Outline Class hierarchy and inheritance Method overriding or overloading, polymorphism Abstract classes Casting and instanceof/getclass Class Object Exception class hierarchy Some Reminders Interfaces

More information

Zhifu Pei CSCI5448 Spring 2011 Prof. Kenneth M. Anderson

Zhifu Pei CSCI5448 Spring 2011 Prof. Kenneth M. Anderson Zhifu Pei CSCI5448 Spring 2011 Prof. Kenneth M. Anderson Introduction History, Characteristics of Java language Java Language Basics Data types, Variables, Operators and Expressions Anatomy of a Java Program

More information

The software crisis. code reuse: The practice of writing program code once and using it in many contexts.

The software crisis. code reuse: The practice of writing program code once and using it in many contexts. Inheritance The software crisis software engineering: The practice of conceptualizing, designing, developing, documenting, and testing largescale computer programs. Large-scale projects face many issues:

More information

JAVA REVIEW cs2420 Introduction to Algorithms and Data Structures Spring 2015

JAVA REVIEW cs2420 Introduction to Algorithms and Data Structures Spring 2015 JAVA REVIEW cs2420 Introduction to Algorithms and Data Structures Spring 2015 1 administrivia 2 -Lab 0 posted -getting started with Eclipse -Java refresher -this will not count towards your grade -TA office

More information

Exam Duration: 2hrs and 30min Software Design

Exam Duration: 2hrs and 30min Software Design Exam Duration: 2hrs and 30min. 433-254 Software Design Section A Multiple Choice (This sample paper has less questions than the exam paper The exam paper will have 25 Multiple Choice questions.) 1. Which

More information

Selected Java Topics

Selected Java Topics Selected Java Topics Introduction Basic Types, Objects and Pointers Modifiers Abstract Classes and Interfaces Exceptions and Runtime Exceptions Static Variables and Static Methods Type Safe Constants Swings

More information

Chapter 3 Classes. Activity The class as a file drawer of methods. Activity Referencing static methods

Chapter 3 Classes. Activity The class as a file drawer of methods. Activity Referencing static methods Chapter 3 Classes Lesson page 3-1. Classes Activity 3-1-1 The class as a file drawer of methods Question 1. The form of a class definition is: public class {

More information

Big software. code reuse: The practice of writing program code once and using it in many contexts.

Big software. code reuse: The practice of writing program code once and using it in many contexts. Inheritance Big software software engineering: The practice of conceptualizing, designing, developing, documenting, and testing largescale computer programs. Large-scale projects face many issues: getting

More information

Object Oriented Programming: In this course we began an introduction to programming from an object-oriented approach.

Object Oriented Programming: In this course we began an introduction to programming from an object-oriented approach. CMSC 131: Chapter 28 Final Review: What you learned this semester The Big Picture Object Oriented Programming: In this course we began an introduction to programming from an object-oriented approach. Java

More information

Java Primer 1: Types, Classes and Operators

Java Primer 1: Types, Classes and Operators Java Primer 1 3/18/14 Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia, and M. H. Goldwasser, Wiley, 2014 Java Primer 1: Types,

More information

1 Shyam sir JAVA Notes

1 Shyam sir JAVA Notes 1 Shyam sir JAVA Notes 1. What is the most important feature of Java? Java is a platform independent language. 2. What do you mean by platform independence? Platform independence means that we can write

More information

Day 4. COMP1006/1406 Summer M. Jason Hinek Carleton University

Day 4. COMP1006/1406 Summer M. Jason Hinek Carleton University Day 4 COMP1006/1406 Summer 2016 M. Jason Hinek Carleton University today s agenda assignments questions about assignment 2 a quick look back constructors signatures and overloading encapsulation / information

More information

C12a: The Object Superclass and Selected Methods

C12a: The Object Superclass and Selected Methods CISC 3115 TY3 C12a: The Object Superclass and Selected Methods Hui Chen Department of Computer & Information Science CUNY Brooklyn College 10/4/2018 CUNY Brooklyn College 1 Outline The Object class and

More information

COMPUTER SCIENCE DEPARTMENT PICNIC. Operations. Push the power button and hold. Once the light begins blinking, enter the room code

COMPUTER SCIENCE DEPARTMENT PICNIC. Operations. Push the power button and hold. Once the light begins blinking, enter the room code COMPUTER SCIENCE DEPARTMENT PICNIC Welcome to the 2016-2017 Academic year! Meet your faculty, department staff, and fellow students in a social setting. Food and drink will be provided. When: Saturday,

More information

Java Inheritance. Written by John Bell for CS 342, Spring Based on chapter 6 of Learning Java by Niemeyer & Leuck, and other sources.

Java Inheritance. Written by John Bell for CS 342, Spring Based on chapter 6 of Learning Java by Niemeyer & Leuck, and other sources. Java Inheritance Written by John Bell for CS 342, Spring 2018 Based on chapter 6 of Learning Java by Niemeyer & Leuck, and other sources. Review Which of the following is true? A. Java classes may either

More information

Two Types of Types. Primitive Types in Java. Using Primitive Variables. Class #07: Java Primitives. Integer types.

Two Types of Types. Primitive Types in Java. Using Primitive Variables. Class #07: Java Primitives. Integer types. Class #07: Java Primitives Software Design I (CS 120): M. Allen, 13 Sep. 2018 Two Types of Types So far, we have mainly been dealing with objects, like DrawingGizmo, Window, Triangle, that are: 1. Specified

More information

(800) Toll Free (804) Fax Introduction to Java and Enterprise Java using Eclipse IDE Duration: 5 days

(800) Toll Free (804) Fax   Introduction to Java and Enterprise Java using Eclipse IDE Duration: 5 days Course Description This course introduces the Java programming language and how to develop Java applications using Eclipse 3.0. Students learn the syntax of the Java programming language, object-oriented

More information

Object Oriented Programming is a programming method that combines: Advantage of Object Oriented Programming

Object Oriented Programming is a programming method that combines: Advantage of Object Oriented Programming Overview of OOP Object Oriented Programming is a programming method that combines: a) Data b) Instructions for processing that data into a self-sufficient object that can be used within a program or in

More information

Prelim 1 Solutions. CS 2110, March 10, 2015, 5:30 PM Total Question True False. Loop Invariants Max Score Grader

Prelim 1 Solutions. CS 2110, March 10, 2015, 5:30 PM Total Question True False. Loop Invariants Max Score Grader Prelim 1 Solutions CS 2110, March 10, 2015, 5:30 PM 1 2 3 4 5 Total Question True False Short Answer Recursion Object Oriented Loop Invariants Max 20 15 20 25 20 100 Score Grader The exam is closed book

More information

CMSC 331 Second Midterm Exam

CMSC 331 Second Midterm Exam 1 10/ 2 10/ 3 60/ 331 First Midterm Exam 16 November 2004 4 10/ 5 20/ CMSC 331 Second Midterm Exam 6 30/ 7 10/ Name: Username: 150/ You will have seventy-five (75) minutes to complete this closed book

More information

Announcements for the Class

Announcements for the Class Lecture 2 Classes Announcements for the Class Readings Section 1.4, 1.5 in text Section 3.1 in text Optional: PLive CD that comes with text References in text Assignment Assignment 1 due next week Due

More information

Full file at Chapter 2 - Inheritance and Exception Handling

Full file at   Chapter 2 - Inheritance and Exception Handling Chapter 2 - Inheritance and Exception Handling TRUE/FALSE 1. The superclass inherits all its properties from the subclass. ANS: F PTS: 1 REF: 76 2. Private members of a superclass can be accessed by a

More information

Graphical Interface and Application (I3305) Semester: 1 Academic Year: 2017/2018 Dr Antoun Yaacoub

Graphical Interface and Application (I3305) Semester: 1 Academic Year: 2017/2018 Dr Antoun Yaacoub Lebanese University Faculty of Science Computer Science BS Degree Graphical Interface and Application (I3305) Semester: 1 Academic Year: 2017/2018 Dr Antoun Yaacoub 2 Crash Course in JAVA Classes A Java

More information

CS 251 Intermediate Programming Inheritance

CS 251 Intermediate Programming Inheritance CS 251 Intermediate Programming Inheritance Brooke Chenoweth University of New Mexico Spring 2018 Inheritance We don t inherit the earth from our parents, We only borrow it from our children. What is inheritance?

More information

CSE 331 Summer 2017 Final Exam. The exam is closed book and closed electronics. One page of notes is allowed.

CSE 331 Summer 2017 Final Exam. The exam is closed book and closed electronics. One page of notes is allowed. Name Solution The exam is closed book and closed electronics. One page of notes is allowed. The exam has 6 regular problems and 1 bonus problem. Only the regular problems will count toward your final exam

More information

I pledge by honor that I will not discuss this exam with anyone until my instructor reviews the exam in the class.

I pledge by honor that I will not discuss this exam with anyone until my instructor reviews the exam in the class. Name: Covers Chapters 1-3 50 mins CSCI 1301 Introduction to Programming Armstrong Atlantic State University Instructor: Dr. Y. Daniel Liang I pledge by honor that I will not discuss this exam with anyone

More information

The Object Class. java.lang.object. Important Methods In Object. Mark Allen Weiss Copyright 2000

The Object Class. java.lang.object. Important Methods In Object. Mark Allen Weiss Copyright 2000 The Object Class Mark Allen Weiss Copyright 2000 1/4/02 1 java.lang.object All classes either extend Object directly or indirectly. Makes it easier to write generic algorithms and data structures Makes

More information

Polymorphism 2/12/2018. Which statement is correct about overriding private methods in the super class?

Polymorphism 2/12/2018. Which statement is correct about overriding private methods in the super class? Which statement is correct about overriding private methods in the super class? Peer Instruction Polymorphism Please select the single correct answer. A. Any derived class can override private methods

More information

OBJECT ORİENTATİON ENCAPSULATİON

OBJECT ORİENTATİON ENCAPSULATİON OBJECT ORİENTATİON Software development can be seen as a modeling activity. The first step in the software development is the modeling of the problem we are trying to solve and building the conceptual

More information

Prelim 1. CS 2110, 14 March 2017, 5:30 PM Total Question Name Short answer. OO Recursion Loop invariants Max Score Grader

Prelim 1. CS 2110, 14 March 2017, 5:30 PM Total Question Name Short answer. OO Recursion Loop invariants Max Score Grader Prelim 1 CS 2110, 14 March 2017, 5:30 PM 1 2 3 4 5 Total Question Name Short answer OO Recursion Loop invariants Max 1 36 33 15 15 100 Score Grader The exam is closed ook and closed notes. Do not egin

More information

Prelim 1. CS 2110, March 15, 2016, 5:30 PM Total Question Name True False. Short Answer

Prelim 1. CS 2110, March 15, 2016, 5:30 PM Total Question Name True False. Short Answer Prelim 1 CS 2110, March 15, 2016, 5:30 PM 0 1 2 3 4 5 Total Question Name True False Short Answer Object- Oriented Recursion Loop Invariants Max 1 20 14 25 19 21 100 Score Grader The exam is closed book

More information

Inheritance -- Introduction

Inheritance -- Introduction Inheritance -- Introduction Another fundamental object-oriented technique is called inheritance, which, when used correctly, supports reuse and enhances software designs Chapter 8 focuses on: the concept

More information

Subclass Gist Example: Chess Super Keyword Shadowing Overriding Why? L10 - Polymorphism and Abstract Classes The Four Principles of Object Oriented

Subclass Gist Example: Chess Super Keyword Shadowing Overriding Why? L10 - Polymorphism and Abstract Classes The Four Principles of Object Oriented Table of Contents L01 - Introduction L02 - Strings Some Examples Reserved Characters Operations Immutability Equality Wrappers and Primitives Boxing/Unboxing Boxing Unboxing Formatting L03 - Input and

More information

Today. Book-keeping. Inheritance. Subscribe to sipb-iap-java-students. Slides and code at Interfaces.

Today. Book-keeping. Inheritance. Subscribe to sipb-iap-java-students. Slides and code at  Interfaces. Today Book-keeping Inheritance Subscribe to sipb-iap-java-students Interfaces Slides and code at http://sipb.mit.edu/iap/java/ The Object class Problem set 1 released 1 2 So far... Inheritance Basic objects,

More information

Highlights of Last Week

Highlights of Last Week Highlights of Last Week Refactoring classes to reduce coupling Passing Object references to reduce exposure of implementation Exception handling Defining/Using application specific Exception types 1 Sample

More information

Basic Object-Oriented Concepts. 5-Oct-17

Basic Object-Oriented Concepts. 5-Oct-17 Basic Object-Oriented Concepts 5-Oct-17 Concept: An object has behaviors In old style programming, you had: data, which was completely passive functions, which could manipulate any data An object contains

More information

CS/ENGRD 2110 FALL Lecture 5: Local vars; Inside-out rule; constructors

CS/ENGRD 2110 FALL Lecture 5: Local vars; Inside-out rule; constructors 1 CS/ENGRD 2110 FALL 2015 Lecture 5: Local vars; Inside-out rule; constructors http://courses.cs.cornell.edu/cs2110 References to text and JavaSummary.pptx 2 Local variable: variable declared in a method

More information

Agenda. Objects and classes Encapsulation and information hiding Documentation Packages

Agenda. Objects and classes Encapsulation and information hiding Documentation Packages Preliminaries II 1 Agenda Objects and classes Encapsulation and information hiding Documentation Packages Inheritance Polymorphism Implementation of inheritance in Java Abstract classes Interfaces Generics

More information

Language Features. 1. The primitive types int, double, and boolean are part of the AP

Language Features. 1. The primitive types int, double, and boolean are part of the AP Language Features 1. The primitive types int, double, and boolean are part of the AP short, long, byte, char, and float are not in the subset. In particular, students need not be aware that strings are

More information

CS211 Prelim Oct 2001 NAME NETID

CS211 Prelim Oct 2001 NAME NETID This prelim has 4 questions. Be sure to answer them all. Please write clearly, and show all your work. It is difficult to give partial credit if all we see is a wrong answer. Also, be sure to place suitable

More information

Type Hierarchy. Comp-303 : Programming Techniques Lecture 9. Alexandre Denault Computer Science McGill University Winter 2004

Type Hierarchy. Comp-303 : Programming Techniques Lecture 9. Alexandre Denault Computer Science McGill University Winter 2004 Type Hierarchy Comp-303 : Programming Techniques Lecture 9 Alexandre Denault Computer Science McGill University Winter 2004 February 16, 2004 Lecture 9 Comp 303 : Programming Techniques Page 1 Last lecture...

More information

PREPARING FOR PRELIM 1

PREPARING FOR PRELIM 1 PREPARING FOR PRELIM 1 CS 1110: FALL 2012 This handout explains what you have to know for the first prelim. There will be a review session with detailed examples to help you study. To prepare for the prelim,

More information

CSE 331 Final Exam 3/16/15 Sample Solution

CSE 331 Final Exam 3/16/15 Sample Solution Question 1. (12 points, 3 each) A short design exercise. Suppose Java did not include a Set class in the standard library and we need to store a set of Strings for an application. We know that the maximum

More information

CMSC 331 Second Midterm Exam

CMSC 331 Second Midterm Exam 1 20/ 2 80/ 331 First Midterm Exam 11 November 2003 3 20/ 4 40/ 5 10/ CMSC 331 Second Midterm Exam 6 15/ 7 15/ Name: Student ID#: 200/ You will have seventy-five (75) minutes to complete this closed book

More information

CSC207H: Software Design. Java + OOP. CSC207 Winter 2018

CSC207H: Software Design. Java + OOP. CSC207 Winter 2018 Java + OOP CSC207 Winter 2018 1 Why OOP? Modularity: code can be written and maintained separately, and easily passed around the system Information-hiding: internal representation hidden from the outside

More information

Computer Science II (20073) Week 1: Review and Inheritance

Computer Science II (20073) Week 1: Review and Inheritance Computer Science II 4003-232-01 (20073) Week 1: Review and Inheritance Richard Zanibbi Rochester Institute of Technology Review of CS-I Hardware and Software Hardware Physical devices in a computer system

More information

Inheritance. Inheritance Reserved word protected Reserved word super Overriding methods Class Hierarchies Reading for this lecture: L&L

Inheritance. Inheritance Reserved word protected Reserved word super Overriding methods Class Hierarchies Reading for this lecture: L&L Inheritance Inheritance Reserved word protected Reserved word super Overriding methods Class Hierarchies Reading for this lecture: L&L 9.1 9.4 1 Inheritance Inheritance allows a software developer to derive

More information

Argument Passing All primitive data types (int etc.) are passed by value and all reference types (arrays, strings, objects) are used through refs.

Argument Passing All primitive data types (int etc.) are passed by value and all reference types (arrays, strings, objects) are used through refs. Local Variable Initialization Unlike instance vars, local vars must be initialized before they can be used. Eg. void mymethod() { int foo = 42; int bar; bar = bar + 1; //compile error bar = 99; bar = bar

More information

1- Differentiate between extends and implements keywords in java? 2- What is wrong with this code:

1- Differentiate between extends and implements keywords in java? 2- What is wrong with this code: 1- Differentiate between extends and implements keywords in java? 2- What is wrong with this code: public double getsalary() double basesalary = getsalary(); return basesalary + bonus; 3- What does the

More information

Student Performance Q&A:

Student Performance Q&A: Student Performance Q&A: 2016 AP Computer Science A Free-Response Questions The following comments on the 2016 free-response questions for AP Computer Science A were written by the Chief Reader, Elizabeth

More information

BBM 102 Introduction to Programming II Spring Inheritance

BBM 102 Introduction to Programming II Spring Inheritance BBM 102 Introduction to Programming II Spring 2018 Inheritance 1 Today Inheritance Notion of subclasses and superclasses protected members UML Class Diagrams for inheritance 2 Inheritance A form of software

More information

CS Internet programming Unit- I Part - A 1 Define Java. 2. What is a Class? 3. What is an Object? 4. What is an Instance?

CS Internet programming Unit- I Part - A 1 Define Java. 2. What is a Class? 3. What is an Object? 4. What is an Instance? CS6501 - Internet programming Unit- I Part - A 1 Define Java. Java is a programming language expressly designed for use in the distributed environment of the Internet. It was designed to have the "look

More information

Assoc. Prof. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved.

Assoc. Prof. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved. Assoc. Prof. Marenglen Biba (C) 2010 Pearson Education, Inc. All Inheritance A form of software reuse in which a new class is created by absorbing an existing class s members and enriching them with

More information