Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Size: px
Start display at page:

Download "Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written."

Transcription

1 QUEEN'S UNIVERSIY SCHOOL O COMPUING HAND IN Answers Are Recorded on Exam Paper CMPE212, WINER ERM, 2016 INAL EXAMINAION 9am to 12pm, 19 APRIL 2016 Instructor: Alan McLeod If the instructor is unavailable in the examination room and if doubt exists as to the interpretation of any problem, the candidate is urged to submit with the answer paper a clear statement of any assumptions made. Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. Please write your answers in the boxes provided. Extra space is available on the last page of the exam. he back of any page can be used for rough work. his exam is three hours long and refers exclusively to the use of the Java language. Comments are not required in the code you write. or full marks, code must be efficient as well as correct. his is a closed book exam. No computers or calculators are allowed. Student Number: SOLUION Problem 1: / 40 Problem 4: / 10 Problem 2: / 20 Problem 5: / 10 Problem 3: / 10 Problem 6: / 50 OAL: / 140 his material is copyrighted and is for the sole use of students registered in CMPE212 and writing this exam. his material shall not be distributed or disseminated. ailure to abide by these conditions is a breach of copyright and may also constitute a breach of academic integrity under the University Senate's Academic Integrity Policy Statement.

2 Student Number: Page 2 of 24 Problem 1) [40 marks] Indicate if each of the following statements is rue or alse by writing a or on the line before the statement: Proper object encapsulation is based on having attributes declared as private. he implements keyword is used to create a child class from a parent class. he first line of code in the constructor of a child class must be a call to the constructor of the parent class. An immutable class has a mutator for each attribute. An attribute of type String must be cloned by its accessor to avoid a privacy leak. he keyword this can be used to access the immediate parent object from within the child object. A fully concrete child class must implement all abstract methods inherited from an abstract parent class. An interface can contain final static attributes. An object can be declared to be of an interface type. An abstract class can be instantiated. It is not possible to overload constructors. Only constructors can throw exceptions. he throws decoration is used in a class declaration to indicate that the class contains methods that throw exceptions. A constructor must be invoked during instantiation. Java automatically provides a default constructor for a class that does not have its own constructor.

3 Student Number: Page 3 of 24 Problem 1, Cont.) It is possible to define a class within another class. An outer class can only invoke non-static inner class methods from an instance of that inner class. A child class instance can be assigned to a pointer of a parent class type. Object is the base class for all classes in the Java API. Late binding is another name for the process of polymorphism. Early binding must be satisfied for the process of polymorphism to take place. Only attributes can be declared outside a class definition. In JavaX, the root Pane class does not have a built-in layout manager algorithm. It can only use absolute layout positions. he StackPane class is used to place nodes in a grid layout. When using a GridPane, nodes can be added to any row, column position in any order. Visible grid lines can be used to help with layout when using a GridPane. By default, a GridPane column is set to be as wide as the widest node in that column. It is not possible to make a GridPane row any taller than the tallest node in that row. he relative positions of nodes within an HBox pane can change if the pane size changes. he relative positions of nodes within a ilepane can change if the pane size changes.

4 Student Number: Page 4 of 24 Problem 1, Cont.) A *.css file or stylesheet can be used to change the appearance of individual nodes, all nodes of a certain type or all nodes in a JavaX window. Only one node can be the root node for a Scene object. All nodes must be added directly to the Stage object so that they can be seen. A JavaX window is modal by default. An event handler to listen for a mouse click event can implement the EventHandler<ActionEvent> interface. he EventHandler<ActionEvent> interface is a functional interface. he root node is typically a Pane object. A Button s.setonaction() mutator can be used to attach an event handler to the button. It is not possible to use a Lambda function to define an event handler. A Lambda function can only contain a single line of code. A Lambda function can only be written for methods defined in a functional interface that accept a single argument. Settings made in the stylesheet will override any appearance settings made in the *.fxml file in the same JavaX project. he *.fxml file must know the name and folder location of the controller *.java file that it is supposed to work with. Nodes must be instantiated in the controller *.java file rather than in the *.fxml file that it is associated with. he initialize() method in the controller *.java class is invoked only after all nodes have been injected into the file.

5 Student Number: Page 5 of 24 Problem 1, Cont.) annotation is used to specify methods and attributes in the controller class that are not to be processed by the *.fxml file. By default, built-in JavaX dialog windows are modal in behaviour. It is not possible to change the graphic image used in a JavaX dialog window. Dialogs cannot be used to obtain text from the user. Change listeners must be added to node properties rather than to the node itself. A change listener added to a text field property can obtain the text in the field as it was before it was changed by the user. Change listeners can be used to detect changes to spinners and sliders. Drawing methods can be invoked directly on an instance of a Canvas object. he border colour of a filled oval can be different from its fill colour. he (0, 0) pixel position in a Canvas object is the lower, left corner of the Canvas. he Canvas object is not capable of displaying images loaded from files. A Canvas object can interact with the cursor once an event handler has been added to the Canvas. A ransition animation can be used to animate several nodes at once. A imeline animation can only be constructed with a single Keyrame object. A Duration object must be supplied to the constructor of a Keyrame object. A Duration object is used to specify the time delay between Keyrame objects.

6 Student Number: Page 6 of 24 Problem 1, Cont.) An Animationimer object can be used to create an event that will be triggered every time the window s frame is re-drawn. An Animationimer object must be attached to a imeline object. A imeline object is started as soon as it is instantiated. A imeline object cannot be halted until the application containing the object is closed. Keyrame objects can be used to trigger events when the Keyrame has completed. here is no point in designing an animation that updates at any rate higher than the monitor refresh rate. A loop that endlessly iterates until a second has passed and then re-starts can be added to the Application thread in a JavaX program without changing the responsiveness of the window. A javafx.concurrent.ask object cannot access scenegraph nodes directly, but must bind with their properties instead. A ask object cannot be re-started. A ask object is a generic class. he implementation of a ask object requires you to override the call() method that returns an object of type. A javafx.concurrent.service object is used to manage a ask object. A Service object cannot be re-started. A Service object must be wrapped in a hread object in order to be changed to a Daemon thread. Daemon threads are automatically halted before any user application threads are stopped. here is no way to change the thread priority of a thread in a JavaX program.

7 Student Number: Page 7 of 24 Problem 1, Cont.) he hread.sleep() method will not propagate a thread interrupt exception. he hread.yield() method is used to halt a thread s execution. or I am really happy that this is the last true/false question! Problem 2) [20 marks]: Answer the following questions as briefly as possible: What is the underlying data structure used by an ArrayList<> collection? Object[] What is the convenience obtained by a class when it implements the Comparable<> interface? hat object can be sorted by built-in sorting methods from the Java API such as Arrays.sort(). What is the reason for making non-final attributes private? Private attributes cannot be changed directly from outside the object. If permitted at all, changes can only be made through mutator methods, which can check possible attribute values for legality. What is the advantage to declaring class members static? All instances of that class will share the same static member they are not duplicated, making memory use more efficient. What is a null pointer? A null pointer is a variable of an object type that has not been assigned to point to an instantiated object. It does not yet contain a memory address.

8 Student Number: Page 8 of 24 Problem 2, Cont.) What does it mean to say that an exception is propagated after it is thrown? If an exception is thrown but not caught inside the method in which it was thrown, the method will be halted and the exception will be propagated to the next method down on the call stack. Name one advantage of using inheritance. Avoids code duplication. Enforces class structure on child classes. Allows the use of polymorphism. Why is a try-with-resources block better than a normal try-catch block when used with ile I/O? Resources in a try-with-resources block will be automatically closed as soon as the end of the try block is reached. No explicit.close() calls are required, which is good because they will not work well if the stream is already in an erroneous state. Which file format binary or text produces the most compact file for storing floating point numeric data and why? Binary. Numbers are stored using the exact same bit pattern as used in RAM 4 bytes for a float, 8 bytes for a double. o store numbers in a text file all digits would have to become text characters taking up at least one byte each. What is a Scene Graph as used in JavaX? A Scene Graph refers to the hierarchy of nodes that will be added to the root of a Scene object. A node is an individual control or container in a window.

9 Student Number: Page 9 of 24 Problem 3) [10 marks] Provide the console window output of each of the following println statements. If you think the statement will cause an error, write error instead. System.out.println ( 15 / 2.0 );... System.out.println ( (double)( 7 / 2 ) );... System.out.println ( 6 * ( 2 / 3 ) + 7 );... System.out.println ( true && 1 );... System.out.println ( 6 * 2 / );... System.out.println ( 6 * 20 / ( ) );... System.out.println ( 5 > 2 3 <= 1 );... System.out.println ( 2 ** 3 );... System.out.println ( 26 % 3 );... System.out.println ( * / 5-1 );... System.out.println ( true && 9!= 7 );... System.out.println ("4" );... System.out.println ( "7" - 4);... System.out.println ( 5 > 2 && 6!= 5 7 < 3 );... System.out.println ( <> 13 );... System.out.println ( 2.4 / (int) 1.2 );... System.out.println ( (int) ( 9.6 / 2.0 ) );... System.out.println ( > 3 && 9 >= );... System.out.println ( Character.isDigit("123") );... System.out.println ( Character.toLowerCase('B') ); error true error 2 10 true 431 error true error true error b

10 Student Number: Page 10 of 24 Problem 4) [10 marks] Write the output of the following complete program, which runs without error, in the box provided: public class Problem1 { public static double fiddle(int num1, int[] nums1, int[] nums2, String str) { str = str.tolowercase(); int size = str.length(); String flipped = str.charat(size 1) + str.substring(1, size 1) + str.charat(0); System.out.println(flipped); num1 = size; for (int num : nums1) num *= 10; System.out.println(nums1[0]); double sum = 0; for (int i = 0; i < nums2.length; i++) { sum += nums2[i]; nums2[i] *= 10; System.out.println(nums2[0]); return sum; // Displays numbers on one line public static void showarray(int[] array) { System.out.print("Array: "); for (int num : array) System.out.print(num + ", "); System.out.println(); public static void main(string[] args) { int[] array1 = {2, 3, 4, 5; int[] array2 = {1, 2, 3, 4; String astring = "Hello Class!"; int anum = 20; double aval = fiddle(anum, array1, array2, astring); System.out.println(aNum); showarray(array1); showarray(array2); System.out.println(aString); System.out.println(aVal);!ello classh Array: 2, 3, 4, 5, Array: 10, 20, 30, 40, Hello Class! 10.0

11 Student Number: Page 11 of 24 Problem 5) [10 marks] Here are a bunch of classes and an interface from the same Java project: public abstract class Base { public int sum(int a, int b) { return a + b; public int multiply(int a, int b) { return a * b; public abstract int subtract(int a, int b); // end Base interface Dividing { int divide(int a, int b) throws DivideByZero; // end Dividing public class DivideByZero extends Exception { public DivideByZero(String message) { super(message); // end DivideByZero public class Concrete extends Missing { public int multiply(int a, int b, int c) { return a * b * c; // end Concrete here are two more classes in this project. he one on the next page contains a main method that tests the other classes:

12 Student Number: Page 12 of 24 Problem 5, Cont.) public class Demonstration { public static int remainder(int a, int b) { return a % b; public static void main(string[] args) { Concrete test = new Concrete(); // Prints: System.out.println(test.sum(4, 5)); // 9 System.out.println(test.sum(4, 5, 6)); // 15 System.out.println(remainder(12, 5)); // 2 System.out.println(test.multiply(4, 5)); // 20 System.out.println(test.multiply(3, 4, 5)); // 60 System.out.println(test.subtract(4, 5)); // 1 try { System.out.println(test.divide(10, 0)); catch (DivideByZero e) { System.out.println(e.getMessage()); //Attempt to divide by 0! try { System.out.println(test.divide(10, 2)); // 5 catch (DivideByZero e) { System.out.println(e.getMessage()); try { Dividing dest = new Missing(); System.out.println(dest.divide(15, 2)); // 7 catch (DivideByZero e) { System.out.println(e.getMessage()); // end main // end Demonstration As you can see the listing shown above contains the output of the program when run as in-line comments. One class is Missing. he Missing class extends one class and implements an interface. Write the Missing class on the next page:

13 Student Number: Page 13 of 24 Problem 5, Cont.) public class Missing extends Base implements Dividing { public int subtract(int a, int b) { return a b; public int divide(int a, int b) throws DivideByZero { if (b == 0) throw new DivideByZero("Attempt to divide by zero!"); return a / b; public int sum(int a, int b, int c) { return a + b + c;

14 Student Number: Page 14 of 24 Problem 6) [50 marks] or this problem you are going to write a properly encapsulated class call CallLog that is designed to hold data for a call centre s single phone call response. Start below by writing an exception class called LogException that will be used by the CallLog class: Write the LogException class below: public class LogException extends Exception { 2 marks public LogException(String message) { super(message); he CallLog class encapsulates the following attributes: he operator s name. Must contain at least one space and be at least three characters in length. he month for the call. An int that must lie between 1 and 12 inclusive. he day for the call. An int that must lie between 1 and 31 inclusive. he start time for the call as an int in the form hhmm, where hh is the hour that must be between 08 and 20 (8am to 8pm) and mm is the minute that must lie between 00 and 59. he finish time for the call in the same form as the start time. he finish time must be later than or the same as the start time. If an attempt is made to instantiate or mutate a CallLog instance with illegal arguments, the constructor or mutator being used must throw the LogException exception with an appropriate message. he CallLog class has one constructor that accepts arguments for all parameters and a second constructor that does not need the finish time, but assumes that the finish time is the same as the start time. Write a mutator for each attribute.

15 Student Number: Page 15 of 24 Problem 6, Cont.) You can write as many accessors as you need, but at a minimum you must have accessors for the name, the month and the day. As you continue to work on this problem you may find that additional accessors will help simplify your code. You also need to write the other four standard methods: compareo, equals, tostring and clone. Comparison using compareo is based just on the full starting time of the call. his means a time that consists of the month, the day and the starting time of the call. You will see examples of the use of this method later in the description of this problem. Equality is defined as the name, the month, the day and the starting time all being equal. You must override the equals method inherited from the Object class. You will see examples of the output of the tostring method later on in this description. he clone method must return a deep copy of the current CallLog object. All string comparisons in this problem can be assumed to be case sensitive. You can use the String methods.equals(otherstring) which returns a boolean and.compareo(otherstring) which returns a negative number if the supplied string comes after the current string (the one used to invoke the method) in the alphabet, zero if they are equal and a positive number if the supplied string comes before the current string. Start writing the CallLog class below and continue on the next five pages. Note that this problem continues after these five blank pages and that output examples are provided at the end of the problem statement. he CallLog class: 32 marks public class CallLog implements Comparable<CallLog> { private String name; private int month; private int day; private int startime; private int finishime;

16 Student Number: Page 16 of 24 Problem 6, Cont.) he CallLog class, Cont.: public CallLog(String name, int month, int day, int start, int finish) throws LogException { setname(name); setmonth(month); setday(day); setstart(start); setinish(finish); if (finish < start) throw new LogException("Start time must be before finish time."); public CallLog(String name, int month, int day, int start) throws LogException { this(name, month, day, start, start); public void setname(string name) throws LogException { if (name.length() > 2 && name.contains(" ")) this.name = name; else throw new LogException("Illegal name."); public void setmonth(int month) throws LogException { if (month > 0 && month < 13) this.month = month; else throw new LogException("Illegal month."); public void setday(int day) throws LogException { if (day > 0 && day < 32) this.day = day; else throw new LogException("Illegal day."); private int extractminutes(int time) { return time 100 * (time / 100); public void setstart(int start) throws LogException { if (start >= 800 && start <= 2000 && extractminutes(start) < 60) startime = start; else throw new LogException("Illegal start time.");

17 Student Number: Page 17 of 24 Problem 6, Cont.) he CallLog class, Cont.: public void setinish(int finish) throws LogException { if (finish >= 800 && finish <= 2000 && extractminutes(finish) < 60) finishime = finish; else throw new LogException("Illegal finish time."); public String getname() { return name; public int getmonth() { return month; public int getday() { return day; public int getduration() { int hours = finishime / 100 startime / 100; int minutes = extractminutes(finishime) extractminutes(startime); int duration = hours * 60 + minutes; if (duration == 0) return 1; else return duration; // Must be public if use Lambda function for Comparator<> public int getullime() { return (month * day) * startime; public static int compareowithname(calllog left, CallLog right) { int namecompare = left.name.compareo(right.name); if (namecompare == 0) return left.getullime() right.getullime(); else return namecompare; public int compareo(calllog other) { return getullime() other.getullime();

18 Student Number: Page 18 of 24 Problem 6, Cont.) he CallLog class, Cont.: public boolean equals(object other) { if (other instanceof CallLog) { CallLog olog = (CallLog)other; return olog.name.equals(name) && olog.getullime() == getullime(); return false; public CallLog clone() { CallLog out = null; try { out = new CallLog(name, month, day, startime, finishime); catch (LogException e) { // empty return out; public String tostring() { return "Call log for " + name + " on month " + month + ", day " + day + ", starting at " + startime + ", finishing at " + finishime;

19 Student Number: Page 19 of 24 Problem 6, Cont.) he CallLog class, Cont.:

20 Student Number: Page 20 of 24 Problem 6, Cont.) he CallLog class, Cont.:

21 Student Number: Page 21 of 24 Problem 6, Cont.) Imagine, but do not write (!), another class containing static methods that is using the CallLog object you have just completed. Also, imagine that there are other CallLog child type objects that extend your CallLog class that are designed to hold other pieces of information in addition to the ones you encapsulated above. In the box below, write a static method for inclusion in this class called totalcallime that accepts as arguments: An ArrayList collection of objects of type CallLog or of any object that extends CallLog, An operator s name, A month as an int between 1 and 12, and A day as an int between 1 and 31. his method searches the supplied collection for all objects that have been created for the operator name supplied and for the supplied month and day. It then sums up and returns the total time in minutes for all calls that match the search criteria. If a call has the same finish time as the start time, assume a one minute duration for this call. Write just the totalcallime method below. You may add accessor(s) to the CallLog class above in order to support the work of the totalcallime method if you wish. he totalcallime method: public static int totalcallime(arraylist<? extends CallLog> list, String name, int month, int day) { int sum = 0; for (CallLog item : list) if (item.getname().equals(name) && item.getmonth() == month && item.getday() == day) sum += item.getduration(); return sum; 6 marks

22 Student Number: Page 22 of 24 Problem 6, Cont.) Without all the javadoc comments the Comparable<> interface from the Java API is: package java.lang; public interface Comparable<> { public int compareo( o); And the relevant part of the Comparator<> interface is: package public interface Comparator<> { int compare( o1, o2); he ArrayList.sort() method accepts a Comparator object that can be used to specify the sort criteria to be used by this method. Write a line of code to be included in some method in this other class that will sort an array list called loglist that is of type ArrayList<CallLog> using the ArrayList.sort() method. Note that if you supply null to the.sort() method it sorts using the natural ordering of the objects contained in the ArrayList. loglist.sort(null); 1 mark Write another line of code that uses the ArrayList.sort() method with a Comparator object that changes the ordering to sort first by name then by time. Modify your CallLog class if you wish. loglist.sort(calllog::compareowithname); 9 marks or loglist.sort((calllog left, CallLog right) > { int namecompare = left.getname().compareo(right.getname()); if (namecompare == 0) return left.getullime() right.getullime(); else return namecompare; );

23 Student Number: Page 23 of 24 Problem 6, Cont.) or example, here is the output generated by the code: loglist.foreach(item > System.out.println(item)) for some test data in the same order as it was added to the ArrayList loglist : Call log for Joe Keen on month 2, day 12, starting at 1005, finishing at 1010 Call log for Joe Keen on month 1, day 28, starting at 1005, finishing at 1010 Call log for Joe Keen on month 2, day 12, starting at 905, finishing at 912 Call log for Joe Keen on month 2, day 12, starting at 1407, finishing at 1410 Call log for Joe Keen on month 2, day 12, starting at 1225, finishing at 1227 Call log for Joe Keen on month 2, day 12, starting at 1358, finishing at 1405 Call log for Sue Keen on month 2, day 12, starting at 1005, finishing at 1010 Call log for Joe Keen on month 7, day 12, starting at 1005, finishing at 1010 Call log for Joe Keen on month 2, day 12, starting at 1005, finishing at 1005 Call log for Joe Keen on month 2, day 9, starting at 1105, finishing at 1110 Call log for Joe Keen on month 2, day 14, starting at 1005, finishing at 1010 Call log for Amy Keen on month 2, day 12, starting at 1005, finishing at 1010 he totalcallime method, if invoked for Joe Keen, month 2 and day 12, would return the value of 25 minutes. After sorting using natural ordering, loglist would look like: Call log for Joe Keen on month 1, day 28, starting at 1005, finishing at 1010 Call log for Joe Keen on month 2, day 9, starting at 1105, finishing at 1110 Call log for Joe Keen on month 2, day 12, starting at 905, finishing at 912 Call log for Joe Keen on month 2, day 12, starting at 1005, finishing at 1010 Call log for Sue Keen on month 2, day 12, starting at 1005, finishing at 1010 Call log for Joe Keen on month 2, day 12, starting at 1005, finishing at 1005 Call log for Amy Keen on month 2, day 12, starting at 1005, finishing at 1010 Call log for Joe Keen on month 2, day 12, starting at 1225, finishing at 1227 Call log for Joe Keen on month 2, day 12, starting at 1358, finishing at 1405 Call log for Joe Keen on month 2, day 12, starting at 1407, finishing at 1410 Call log for Joe Keen on month 2, day 14, starting at 1005, finishing at 1010 Call log for Joe Keen on month 7, day 12, starting at 1005, finishing at 1010 After sorting with the new Comparator object: Call log for Amy Keen on month 2, day 12, starting at 1005, finishing at 1010 Call log for Joe Keen on month 1, day 28, starting at 1005, finishing at 1010 Call log for Joe Keen on month 2, day 9, starting at 1105, finishing at 1110 Call log for Joe Keen on month 2, day 12, starting at 905, finishing at 912 Call log for Joe Keen on month 2, day 12, starting at 1005, finishing at 1010 Call log for Joe Keen on month 2, day 12, starting at 1005, finishing at 1005 Call log for Joe Keen on month 2, day 12, starting at 1225, finishing at 1227 Call log for Joe Keen on month 2, day 12, starting at 1358, finishing at 1405 Call log for Joe Keen on month 2, day 12, starting at 1407, finishing at 1410 Call log for Joe Keen on month 2, day 14, starting at 1005, finishing at 1010 Call log for Joe Keen on month 7, day 12, starting at 1005, finishing at 1010 Call log for Sue Keen on month 2, day 12, starting at 1005, finishing at 1010

24 Student Number: Page 24 of 24 Extra Page

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. QUEEN'S UNIVERSITY SCHOOL OF COMPUTING HAND IN Answers Are Recorded on Exam Paper CMPE212, WINTER TERM, 2016 FINAL EXAMINATION 9am to 12pm, 19 APRIL 2016 Instructor: Alan McLeod If the instructor is unavailable

More information

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. QUEEN'S UNIVERSITY SCHOOL OF COMPUTING HAND IN Answers Are Recorded on Question Paper CISC124, FALL TERM, 2015 FINAL EXAMINATION 7pm to 10pm, 15 DECEMBER 2015 Instructor: Alan McLeod If the instructor

More information

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. QUEEN'S UNIVERSIY SCHOOL O COMPUING CISC124, ALL ERM, 2015 INAL EXAMINAION 7pm to 10pm, 15 DECEMBER 2015 Instructor: Alan McLeod HAND IN Answers Are Recorded on Question Paper SOLUION If the instructor

More information

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. QUEEN'S UNIVERSITY SCHOOL OF COMPUTING HAND IN Answers Are Recorded on Question Paper CISC124, WINTER TERM, 2012 FINAL EXAMINATION 9am to 12pm, 26 APRIL 2012 Instructor: Alan McLeod If the instructor is

More information

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. QUEEN'S UNIVERSIY SCHOOL O COMPUING CISC124, WINER ERM, 2011 INAL EXAMINAION 7pm to 10pm, 26 APRIL 2011, Ross Gym HAND IN Answers Are Recorded on Question Paper SOLUION Instructor: Alan McLeod If the instructor

More information

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. HAND IN Answers Are Recorded on Question Paper QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC212, FALL TERM, 2006 FINAL EXAMINATION 7pm to 10pm, 19 DECEMBER 2006, Jeffrey Hall 1 st Floor Instructor: Alan

More information

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. QUEEN'S UNIVERSITY SCHOOL OF COMPUTING HAND IN Answers Are Recorded on Question Paper CMPE212, FALL TERM, 2012 FINAL EXAMINATION 18 December 2012, 2pm Instructor: Alan McLeod If the instructor is unavailable

More information

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. SOLUTION HAND IN Answers Are Recorded on Question Paper QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC212, FALL TERM, 2006 FINAL EXAMINATION 7pm to 10pm, 19 DECEMBER 2006, Jeffrey Hall 1 st Floor Instructor:

More information

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. Solution HAND IN Answers Are Recorded on Question Paper QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC124, WINTER TERM, 2010 FINAL EXAMINATION 2pm to 5pm, 19 APRIL 2010, Dunning Hall Instructor: Alan McLeod

More information

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. QUEEN'S UNIVERSITY SCHOOL OF COMPUTING HAND IN Answers Are Recorded on Question Paper CISC124, WINTER TERM, 2011 FINAL EXAMINATION 7pm to 10pm, 26 APRIL 2011, Ross Gym Instructor: Alan McLeod If the instructor

More information

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. QUEEN'S UNIVERSIY SCHOOL O COMPUING CMPE212, ALL ERM, 2011 INAL EXAMINAION 15 December 2011, 2pm, Grant Hall Instructor: Alan McLeod HAND IN Answers Are Recorded on Question Paper SOLUION If the instructor

More information

Page 1 of 16. Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Page 1 of 16. Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. Page 1 of 16 HAND IN Answers Are Recorded on Question Paper QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC212, FALL TERM, 2005 FINAL EXAMINATION 9am to 12noon, 19 DECEMBER 2005 Instructor: Alan McLeod If

More information

For example, here is a code snippet that supplies a legal data set to the constructor:

For example, here is a code snippet that supplies a legal data set to the constructor: Problem 1) [This problem is longer than what you will see on the quiz. You would not be asked to write as many methods, just one or two of them. This is still good practice, however!] For this problem

More information

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. QUEEN'S UNIVERSITY SCHOOL OF COMPUTING HAND IN Answers Are Recorded on Question Paper CISC124, FALL TERM, 2013 FINAL EXAMINATION 7pm to 10pm, 18 DECEMBER 2013 Instructor: Alan McLeod If the instructor

More information

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. Solution HAND IN Answers Are Recorded on Question Paper QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC212, FALL TERM, 2007 FINAL EXAMINATION 7pm to 10pm, 10 DECEMBER 2007, Jeffery Hall Instructor: Alan McLeod

More information

Page 1 of 16. Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Page 1 of 16. Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. Page 1 of 16 SOLUTION HAND IN Answers Are Recorded on Question Paper QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC212, FALL TERM, 2004 FINAL EXAMINATION 9am to 12noon, 22 DECEMBER 2004 Instructors: Alan

More information

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. HAND IN Answers Are Recorded on Question Paper QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC124, WINTER TERM, 2009 FINAL EXAMINATION 7pm to 10pm, 18 APRIL 2009, Dunning Hall Instructor: Alan McLeod If the

More information

Page 1 of 16. Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Page 1 of 16. Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. Page 1 of 16 SOLUTION HAND IN Answers Are Recorded on Question Paper QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC212, FALL TERM, 2005 FINAL EXAMINATION 9am to 12noon, 19 DECEMBER 2005 Instructor: Alan McLeod

More information

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. HAND IN Answers Are Recorded on Question Paper QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC212, FALL TERM, 2007 FINAL EXAMINATION 7pm to 10pm, 10 DECEMBER 2007, Jeffery Hall Instructor: Alan McLeod If the

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

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC212, FALL TERM, 2010 FINAL EXAMINATION 11 DECEMBER 2010, 9am SOLUTION HAND IN Answers Are Recorded on Question Paper Instructor: Alan McLeod If the instructor

More information

Abstract Classes and Interfaces

Abstract Classes and Interfaces Abstract Classes and Interfaces Reading: Reges and Stepp: 9.5 9.6 CSC216: Programming Concepts Sarah Heckman 1 Abstract Classes A Java class that cannot be instantiated, but instead serves as a superclass

More information

Lecture 3. COMP1006/1406 (the Java course) Summer M. Jason Hinek Carleton University

Lecture 3. COMP1006/1406 (the Java course) Summer M. Jason Hinek Carleton University Lecture 3 COMP1006/1406 (the Java course) Summer 2014 M. Jason Hinek Carleton University today s agenda assignments 1 (graded) & 2 3 (available now) & 4 (tomorrow) a quick look back primitive data types

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

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

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. HAND IN Answers Are Recorded on Question Paper QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC212, FALL TERM, 2009 FINAL EXAMINATION 14 DECEMBER 2009 Instructor: Alan McLeod If the instructor is unavailable

More information

I BCS-031 BACHELOR OF COMPUTER APPLICATIONS (BCA) (Revised) Term-End Examination. June, 2015 BCS-031 : PROGRAMMING IN C ++

I BCS-031 BACHELOR OF COMPUTER APPLICATIONS (BCA) (Revised) Term-End Examination. June, 2015 BCS-031 : PROGRAMMING IN C ++ No. of Printed Pages : 3 I BCS-031 BACHELOR OF COMPUTER APPLICATIONS (BCA) (Revised) Term-End Examination 05723. June, 2015 BCS-031 : PROGRAMMING IN C ++ Time : 3 hours Maximum Marks : 100 (Weightage 75%)

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

CS506 Web Design & Development Final Term Solved MCQs with Reference

CS506 Web Design & Development Final Term Solved MCQs with Reference with Reference I am student in MCS (Virtual University of Pakistan). All the MCQs are solved by me. I followed the Moaaz pattern in Writing and Layout this document. Because many students are familiar

More information

ENCAPSULATION AND POLYMORPHISM

ENCAPSULATION AND POLYMORPHISM MODULE 3 ENCAPSULATION AND POLYMORPHISM Objectives > After completing this lesson, you should be able to do the following: Use encapsulation in Java class design Model business problems using Java classes

More information

COMP 250 Winter 2011 Reading: Java background January 5, 2011

COMP 250 Winter 2011 Reading: Java background January 5, 2011 Almost all of you have taken COMP 202 or equivalent, so I am assuming that you are familiar with the basic techniques and definitions of Java covered in that course. Those of you who have not taken a COMP

More information

This page intentionally left blank

This page intentionally left blank This page intentionally left blank Absolute Java, Global Edition Table of Contents Cover Title Page Copyright Page Preface Acknowledgments Brief Contents Contents Chapter 1 Getting Started 1.1 INTRODUCTION

More information

VALLIAMMAI ENGINEERING COLLEGE

VALLIAMMAI ENGINEERING COLLEGE VALLIAMMAI ENGINEERING COLLEGE SRM Nagar, Kattankulathur 60 0 DEPARTMENT OF INFORMATION TECHNOLOGY QUESTION BANK III SEMESTER CS89- Object Oriented Programming Regulation 07 Academic Year 08 9 Prepared

More information

Day 3. COMP 1006/1406A Summer M. Jason Hinek Carleton University

Day 3. COMP 1006/1406A Summer M. Jason Hinek Carleton University Day 3 COMP 1006/1406A Summer 2016 M. Jason Hinek Carleton University today s agenda assignments 1 was due before class 2 is posted (be sure to read early!) a quick look back testing test cases for arrays

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

Application Development in JAVA. Data Types, Variable, Comments & Operators. Part I: Core Java (J2SE) Getting Started

Application Development in JAVA. Data Types, Variable, Comments & Operators. Part I: Core Java (J2SE) Getting Started Application Development in JAVA Duration Lecture: Specialization x Hours Core Java (J2SE) & Advance Java (J2EE) Detailed Module Part I: Core Java (J2SE) Getting Started What is Java all about? Features

More information

DHANALAKSHMI SRINIVASAN COLLEGE OF ENGINEERING AND TECHNOLOGY ACADEMIC YEAR (ODD SEM)

DHANALAKSHMI SRINIVASAN COLLEGE OF ENGINEERING AND TECHNOLOGY ACADEMIC YEAR (ODD SEM) DHANALAKSHMI SRINIVASAN COLLEGE OF ENGINEERING AND TECHNOLOGY ACADEMIC YEAR 2018-19 (ODD SEM) DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING SUB: OBJECT ORIENTED PROGRAMMING SEM/YEAR: III SEM/ II YEAR

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

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. SOLUTION HAND IN Answers Are Recorded on Question Paper QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC212, FALL TERM, 2008 FINAL EXAMINATION 7pm to 10pm, 17 DECEMBER 2008, Grant Hall Instructor: Alan McLeod

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

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

Introduction to Computing II (ITI 1121) Final Examination

Introduction to Computing II (ITI 1121) Final Examination Université d Ottawa Faculté de génie École de science informatique et de génie électrique University of Ottawa Faculty of Engineering School of Electrical Engineering and Computer Science Introduction

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

The Sun s Java Certification and its Possible Role in the Joint Teaching Material

The Sun s Java Certification and its Possible Role in the Joint Teaching Material The Sun s Java Certification and its Possible Role in the Joint Teaching Material Nataša Ibrajter Faculty of Science Department of Mathematics and Informatics Novi Sad 1 Contents Kinds of Sun Certified

More information

Fall 2017 CISC124 10/1/2017

Fall 2017 CISC124 10/1/2017 CISC124 Today First onq quiz this week write in lab. More details in last Wednesday s lecture. Repeated: The quiz availability times will change to match each lab as the week progresses. Useful Java classes:

More information

Syllabus & Curriculum for Certificate Course in Java. CALL: , for Queries

Syllabus & Curriculum for Certificate Course in Java. CALL: , for Queries 1 CONTENTS 1. Introduction to Java 2. Holding Data 3. Controllin g the f l o w 4. Object Oriented Programming Concepts 5. Inheritance & Packaging 6. Handling Error/Exceptions 7. Handling Strings 8. Threads

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

CSE 142 Su01 Final Exam Sample Solution page 1 of 7

CSE 142 Su01 Final Exam Sample Solution page 1 of 7 CSE 142 Su01 Final Exam Sample Solution page 1 of 7 Answer all of the following questions. READ EACH QUESTION CAREFULLY. Answer each question in the space provided on these pages. Budget your time so you

More information

Fall 2017 CISC124 9/16/2017

Fall 2017 CISC124 9/16/2017 CISC124 Labs start this week in JEFF 155: Meet your TA. Check out the course web site, if you have not already done so. Watch lecture videos if you need to review anything we have already done. Problems

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

DOWNLOAD PDF CORE JAVA APTITUDE QUESTIONS AND ANSWERS

DOWNLOAD PDF CORE JAVA APTITUDE QUESTIONS AND ANSWERS Chapter 1 : Chapter-wise Java Multiple Choice Questions and Answers Interview MCQs Java Programming questions and answers with explanation for interview, competitive examination and entrance test. Fully

More information

CS/B.TECH/CSE(New)/SEM-5/CS-504D/ OBJECT ORIENTED PROGRAMMING. Time Allotted : 3 Hours Full Marks : 70 GROUP A. (Multiple Choice Type Question)

CS/B.TECH/CSE(New)/SEM-5/CS-504D/ OBJECT ORIENTED PROGRAMMING. Time Allotted : 3 Hours Full Marks : 70 GROUP A. (Multiple Choice Type Question) CS/B.TECH/CSE(New)/SEM-5/CS-504D/2013-14 2013 OBJECT ORIENTED PROGRAMMING Time Allotted : 3 Hours Full Marks : 70 The figures in the margin indicate full marks. Candidates are required to give their answers

More information

Module Contact: Dr Gavin Cawley, CMP Copyright of the University of East Anglia Version 1

Module Contact: Dr Gavin Cawley, CMP Copyright of the University of East Anglia Version 1 UNIVERSITY OF EAST ANGLIA School of Computing Sciences Main Series UG Examination 2017-18 PROGRAMMING 1 CMP-4008Y Time allowed: 2 hours Answer FOUR questions. All questions carry equal weight. Notes are

More information

Java Magistère BFA

Java Magistère BFA Java 101 - Magistère BFA Lesson 3: Object Oriented Programming in Java Stéphane Airiau Université Paris-Dauphine Lesson 3: Object Oriented Programming in Java (Stéphane Airiau) Java 1 Goal : Thou Shalt

More information

Computer Science 2 Lecture 4 Inheritance: Trinidad Fruit Stand 02/15/2014 Revision : 1.7

Computer Science 2 Lecture 4 Inheritance: Trinidad Fruit Stand 02/15/2014 Revision : 1.7 Computer Science 2 Lecture 4 Inheritance: Trinidad Fruit Stand 02/15/2014 Revision : 1.7 1 Problem Ralph owns the Trinidad Fruit Stand that sells its fruit on the street, and he wants to use a computer

More information

Java SE 8 Programming

Java SE 8 Programming Oracle University Contact Us: Local: 1800 103 4775 Intl: +91 80 67863102 Java SE 8 Programming Duration: 5 Days What you will learn This Java SE 8 Programming training covers the core language features

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

Binghamton University. CS-140 Fall Problem Solving. Creating a class from scratch

Binghamton University. CS-140 Fall Problem Solving. Creating a class from scratch Problem Solving Creating a class from scratch 1 Recipe for Writing a Class 1. Write the class boilerplate stuff 2. Declare Fields 3. Write Creator(s) 4. Write accessor methods 5. Write mutator methods

More information

Data Types. Lecture2: Java Basics. Wrapper Class. Primitive data types. Bohyung Han CSE, POSTECH

Data Types. Lecture2: Java Basics. Wrapper Class. Primitive data types. Bohyung Han CSE, POSTECH Data Types Primitive data types (2015F) Lecture2: Java Basics Bohyung Han CSE, POSTECH bhhan@postech.ac.kr Type Bits Minimum Value Maximum Value byte 8 128 127 short 16 32768 32767 int 32 2,147,483,648

More information

Course Description. Learn To: : Intro to JAVA SE7 and Programming using JAVA SE7. Course Outline ::

Course Description. Learn To: : Intro to JAVA SE7 and Programming using JAVA SE7. Course Outline :: Module Title Duration : Intro to JAVA SE7 and Programming using JAVA SE7 : 9 days Course Description The Java SE 7 Fundamentals course was designed to enable students with little or no programming experience

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 for Programmers Course (equivalent to SL 275) 36 Contact Hours

Java for Programmers Course (equivalent to SL 275) 36 Contact Hours Java for Programmers Course (equivalent to SL 275) 36 Contact Hours Course Overview This course teaches programmers the skills necessary to create Java programming system applications and satisfies the

More information

Murach s Beginning Java with Eclipse

Murach s Beginning Java with Eclipse Murach s Beginning Java with Eclipse Introduction xv Section 1 Get started right Chapter 1 An introduction to Java programming 3 Chapter 2 How to start writing Java code 33 Chapter 3 How to use classes

More information

Chapter 1 Getting Started

Chapter 1 Getting Started Chapter 1 Getting Started The C# class Just like all object oriented programming languages, C# supports the concept of a class. A class is a little like a data structure in that it aggregates different

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

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

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

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

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

Distributed Systems Recitation 1. Tamim Jabban

Distributed Systems Recitation 1. Tamim Jabban 15-440 Distributed Systems Recitation 1 Tamim Jabban Office Hours Office 1004 Tuesday: 9:30-11:59 AM Thursday: 10:30-11:59 AM Appointment: send an e-mail Open door policy Java: Object Oriented Programming

More information

CSCI-142 Exam 2 Review September 25, 2016 Presented by the RIT Computer Science Community

CSCI-142 Exam 2 Review September 25, 2016 Presented by the RIT Computer Science Community CSCI-142 Exam 2 Review September 25, 2016 Presented by the RIT Computer Science Community http://csc.cs.rit.edu 1. Suppose we are talking about the depth-first search (DFS) algorithm. Nodes are added to

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

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

Java SE 8 Programming

Java SE 8 Programming Oracle University Contact Us: +52 1 55 8525 3225 Java SE 8 Programming Duration: 5 Days What you will learn This Java SE 8 Programming training covers the core language features and Application Programming

More information

Cpt S 122 Data Structures. Course Review Midterm Exam # 2

Cpt S 122 Data Structures. Course Review Midterm Exam # 2 Cpt S 122 Data Structures Course Review Midterm Exam # 2 Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Midterm Exam 2 When: Monday (11/05) 12:10 pm -1pm

More information

Chapter 4 Defining Classes I

Chapter 4 Defining Classes I Chapter 4 Defining Classes I This chapter introduces the idea that students can create their own classes and therefore their own objects. Introduced is the idea of methods and instance variables as the

More information

Implements vs. Extends When Defining a Class

Implements vs. Extends When Defining a Class Implements vs. Extends When Defining a Class implements: Keyword followed by the name of an INTERFACE Interfaces only have method PROTOTYPES You CANNOT create on object of an interface type extends: Keyword

More information

F1 A Java program. Ch 1 in PPIJ. Introduction to the course. The computer and its workings The algorithm concept

F1 A Java program. Ch 1 in PPIJ. Introduction to the course. The computer and its workings The algorithm concept F1 A Java program Ch 1 in PPIJ Introduction to the course The computer and its workings The algorithm concept The structure of a Java program Classes and methods Variables Program statements Comments Naming

More information

CS 112 Programming 2. Lecture 10. Abstract Classes & Interfaces (1) Chapter 13 Abstract Classes and Interfaces

CS 112 Programming 2. Lecture 10. Abstract Classes & Interfaces (1) Chapter 13 Abstract Classes and Interfaces CS 112 Programming 2 Lecture 10 Abstract Classes & Interfaces (1) Chapter 13 Abstract Classes and Interfaces 2 1 Motivations We have learned how to write simple programs to create and display GUI components.

More information

MARKING KEY The University of British Columbia MARKING KEY Computer Science 260 Midterm #1 Examination 12:30 noon, Tuesday, February 14, 2012

MARKING KEY The University of British Columbia MARKING KEY Computer Science 260 Midterm #1 Examination 12:30 noon, Tuesday, February 14, 2012 MARKING KEY The University of British Columbia MARKING KEY Computer Science 260 Midterm #1 Examination 12:30 noon, Tuesday, February 14, 2012 Instructor: K. S. Booth Time: 70 minutes (one hour ten minutes)

More information

CMSC 202 Section 010x Spring Justin Martineau, Tuesday 11:30am

CMSC 202 Section 010x Spring Justin Martineau, Tuesday 11:30am CMSC 202 Section 010x Spring 2007 Computer Science II Final Exam Name: Username: Score Max Section: (check one) 0101 - Justin Martineau, Tuesday 11:30am 0102 - Sandeep Balijepalli, Thursday 11:30am 0103

More information

Introduction to Computing II (ITI 1121) Final Examination

Introduction to Computing II (ITI 1121) Final Examination Introduction to Computing II (ITI 1121) Final Examination Instructor: Marcel Turcotte April 2010, duration: 3 hours Identification Student name: Student number: Signature: Instructions 1. 2. 3. 4. 5. 6.

More information

CSCI 136 Written Exam #0 Fundamentals of Computer Science II Spring 2015

CSCI 136 Written Exam #0 Fundamentals of Computer Science II Spring 2015 CSCI 136 Written Exam #0 Fundamentals of Computer Science II Spring 2015 Name: This exam consists of 6 problems on the following 7 pages. You may use your single-sided handwritten 8 ½ x 11 note sheet during

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

Index COPYRIGHTED MATERIAL

Index COPYRIGHTED MATERIAL Index COPYRIGHTED MATERIAL Note to the Reader: Throughout this index boldfaced page numbers indicate primary discussions of a topic. Italicized page numbers indicate illustrations. A abstract classes

More information

This exam is open book. Each question is worth 3 points.

This exam is open book. Each question is worth 3 points. This exam is open book. Each question is worth 3 points. Page 1 / 15 Page 2 / 15 Page 3 / 12 Page 4 / 18 Page 5 / 15 Page 6 / 9 Page 7 / 12 Page 8 / 6 Total / 100 (maximum is 102) 1. Are you in CS101 or

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

Inheritance. Inheritance allows the following two changes in derived class: 1. add new members; 2. override existing (in base class) methods.

Inheritance. Inheritance allows the following two changes in derived class: 1. add new members; 2. override existing (in base class) methods. Inheritance Inheritance is the act of deriving a new class from an existing one. Inheritance allows us to extend the functionality of the object. The new class automatically contains some or all methods

More information

CMSC 341. Nilanjan Banerjee

CMSC 341. Nilanjan Banerjee CMSC 341 Nilanjan Banerjee http://www.csee.umbc.edu/~nilanb/teaching/341/ Announcements Just when you thought Shawn was going to teach this course! On a serious note: register on Piazza I like my classes

More information

Lecture 36: Cloning. Last time: Today: 1. Object 2. Polymorphism and abstract methods 3. Upcasting / downcasting

Lecture 36: Cloning. Last time: Today: 1. Object 2. Polymorphism and abstract methods 3. Upcasting / downcasting Lecture 36: Cloning Last time: 1. Object 2. Polymorphism and abstract methods 3. Upcasting / downcasting Today: 1. Project #7 assigned 2. equals reconsidered 3. Copying and cloning 4. Composition 11/27/2006

More information

UMBC CMSC 331 Final Exam

UMBC CMSC 331 Final Exam UMBC CMSC 331 Final Exam Name: UMBC Username: You have two hours to complete this closed book exam. We reserve the right to assign partial credit, and to deduct points for answers that are needlessly wordy

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

Midterm Exam CS 251, Intermediate Programming March 6, 2015

Midterm Exam CS 251, Intermediate Programming March 6, 2015 Midterm Exam CS 251, Intermediate Programming March 6, 2015 Name: NetID: Answer all questions in the space provided. Write clearly and legibly, you will not get credit for illegible or incomprehensible

More information

This page intentionally left blank

This page intentionally left blank This page intentionally left blank arting Out with Java: From Control Structures through Objects International Edition - PDF - PDF - PDF Cover Contents Preface Chapter 1 Introduction to Computers and Java

More information

Core Java - SCJP. Q2Technologies, Rajajinagar. Course content

Core Java - SCJP. Q2Technologies, Rajajinagar. Course content Core Java - SCJP Course content NOTE: For exam objectives refer to the SCJP 1.6 objectives. 1. Declarations and Access Control Java Refresher Identifiers & JavaBeans Legal Identifiers. Sun's Java Code

More information

Topics. Java arrays. Definition. Data Structures and Information Systems Part 1: Data Structures. Lecture 3: Arrays (1)

Topics. Java arrays. Definition. Data Structures and Information Systems Part 1: Data Structures. Lecture 3: Arrays (1) Topics Data Structures and Information Systems Part 1: Data Structures Michele Zito Lecture 3: Arrays (1) Data structure definition: arrays. Java arrays creation access Primitive types and reference types

More information

Class, Variable, Constructor, Object, Method Questions

Class, Variable, Constructor, Object, Method Questions Class, Variable, Constructor, Object, Method Questions http://www.wideskills.com/java-interview-questions/java-classes-andobjects-interview-questions https://www.careerride.com/java-objects-classes-methods.aspx

More information

TeenCoder : Java Programming (ISBN )

TeenCoder : Java Programming (ISBN ) TeenCoder : Java Programming (ISBN 978-0-9887070-2-3) and the AP * Computer Science A Exam Requirements (Alignment to Tennessee AP CS A course code 3635) Updated March, 2015 Contains the new 2014-2015+

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

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