Instruction to students:

Size: px
Start display at page:

Download "Instruction to students:"

Transcription

1 Benha University 2 nd Term (2012) Final Exam Class: 2 nd Year Students Subject: Object Oriented Programming Faculty of Computers & Informatics Date: 20/5/2012 Time: 3 hours Examiner: Dr. Essam Halim Instruction to students: 1. Language allowed to answer is the English language. 2. You should attempt 40 out of the 50 MCQ questions in Section I. 3. You should attempt all of Section II (Section II comprises questions 2, 3, and 4). 4. The exam paper is 14 pages long, and is in 2 sections. 5. The approximate allocation of marks is shown in brackets by the questions. 6. Section I contains multiple choice questions. Answer for the multiple choice questions should be written in the next table move it to the answer sheet. Section I : Key answer for the multiple choice questions Questions Questions Questions Questions Questions Page 1 of 15

2 Answer the following questions: Section I [Total 60] Q(1): Multiple choice questions Answer only 40 of the following 50 multiple choice questions, by selecting the correct answer in each. Place the answer on the special MCQ form. Each question [1.5 Mark] 1 If a number is too large to be stored in a variable of the float type, it. A. causes overflow B. causes underflow C. causes no error D. cannot happen in Java 2 What is i printed in the following code? int j = 0; int i = j++ + j * 5; System.out.println("What is i? " + i); A. 0 B. 1 C. 5 D. 6 3 Analyze the following code. import javax.swing.*; public class ShowErrors { int i; int j; String s = JOptionPane.showInputDialog(null, "Enter an integer", "Input", JOptionPane.QUESTION_MESSAGE); j = Integer.parseInt(s); i = (i + 4); A. The program cannot compile because j is not initialized. B. The program cannot compile because i does not have an initial value when it is used in i = i + 4; C. The program compiles but has a runtime error because i does not have an initial value when it is used in i = i + 4; D. The program compiles and runs fine. Page 2 of 15

3 4 Suppose x=10 and y=10 what is x after evaluating the expression (y >= 10) (x-- > 10). A. 9 B. 10 C What is y after the following statement is executed? x = 0; y = (x > 0)? 10 : -10; A. -10 B. 0 C. 10 D. 20 E. Illegal expression 6 How many times will the following code print "Welcome to Java"? int count = 0; do { System.out.println("Welcome to Java"); count++; while (count < 10); A. 8 B. 9 C. 10 D. 11 E. 0 7 Is the following loop correct? for (; ; ); A. Yes B. No 8 How many times is the println statement executed? for (int i = 0; i < 10; i++) for (int j = 0; j < i; j++) System.out.println(i * j) A. 100 B. 20 C. 10 D. 45 Page 3 of 15

4 9 What is sum after the following loop terminates? int sum = 0; int item = 0; do { item++; sum += item; if (sum >= 4) continue; while (item < 5); A. 15 B. 16 C. 17 D Will the following program terminate? int balance = 10; while (true) { if (balance < 9) continue; balance = balance - 9; A. Yes B. No 11 The signature of a method consists of. A. method name B. method name and parameter list C. return type, method name, and parameter list D. parameter list 12 Given the following method static void nprint(string message, int n) { while (n > 0) { System.out.print(message); n--; What is the printout of the call nprint('a', 4)? A. aaaaa B. aaaa C. aaa D. invalid call Page 4 of 15

5 13 The client can use a method without knowing how it is implemented. The details of the implementation are encapsulated in the method and hidden from the client who invokes the method. This is known as. A. information hiding B. encapsulation C. method hiding D. simplifying method 14 is to implement one method in the structure chart at a time from the top to the bottom. A. Bottom-up approach B. Top-down approach C. Bottom-up and top-down approach D. Stepwise refinement 15 Which of the following statements is valid? A. int i = new int(30); B. double d[] = new double[30]; C. int[] i = {3, 4, 3, 2; D. char[] c = new char(); E. char[] c = new char[4]{'a', 'b', 'c', 'd'; 16 Analyze the following code: final int[] x = {1, 2, 3, 4; int[] y = x; x = new int[2]; for (int i = 0; i < y.length; i++) System.out.print(y[i] + " "); A. The program displays B. The program displays 0 0 C. The program has a compile error on the statement x = new int[2], because x is final and cannot be changed. D. The elements in the array x cannot be changed, because x is final. 17 When you return an array from a method, the method returns. A. a copy of the array B. a copy of the first element C. the reference of the array D. the length of the array Page 5 of 15

6 18 Which of the following declarations are correct? A. public static void print(string strings, double numbers) B. public static void print(double numbers, String name) C. public static double print(double d1, double d2) D. public static void print(double numbers) E. public static void print(int n, double numbers) 19 What is the printout of the following program? int[][] values = {{3, 4, 5, 1, {33, 6, 1, 2; for (int row = 0; row < values.length; row++) { System.out.print(m(values[row]) + " "); public static int m(int[] list) { int v = list[0]; for (int i = 1; i < list.length; i++) if (v < list[i]) v = list[i]; return v; A B. 1 1 C. 5 6 D E Which of the following statements are true? A. Multiple constructors can be defined in a class. B. Constructors do not have a return type, not even void. C. Constructors must have the same name as the class itself. D. Constructors are invoked using the new operator when an object is created. 21 Variables that are shared by every instances of a class are. A. public variables B. private variables C. instance variables D. class variables Page 6 of 15

7 22 You should add the static keyword in the place of? in Line in the following code: 1 2 private int age; 3 4 public? int square(int n) { 5 return n * n; public? int getage() { 9 10 A. in line 4 B. in line 8 C. in both line 4 and line 8 D. none 23 Analyze the following code. int n = 2; xmethod(n); System.out.println("n is " + n); void xmethod(int n) { n++; A. The code has a compile error because xmethod does not return a value. B. The code has a compile error because xmethod is not declared static. C. The code prints n is 1. D. The code prints n is 2. E. The code prints n is Analyze the following code: private int t; int x; System.out.println(t); A. The variable t is not initialized and therefore causes errors. B. The variable t is private and therefore cannot be accessed in the main method. C. t is non-static and it cannot be referenced in a static context in the main method. D. The variable x is not initialized and therefore causes errors. E. The program compiles and runs fine. Page 7 of 15

8 25 What is the output of the following program? import java.util.date; Date date = new Date( ); m1(date); System.out.print(date.getTime() + " "); m2(date); System.out.println(date.getTime()); public static void m1(date date) { date = new Date( ); public static void m2(date date) { date.settime( ); A B C D What is the output of the following code? String s1 = "Welcome to Java!"; String s2 = "Welcome to Java!"; if (s1 == s2) System.out.println("s1 and s2 reference to the same String object"); else System.out.println("s1 and s2 reference to different String objects"); A. s1 and s2 reference to the same String object B. s1 and s2 reference to different String objects 27 What is the output of running class C? class A { public A() { System.out.println( "The default constructor of A is invoked"); class B extends A { public B() { System.out.println( "The default constructor of B is invoked"); public class C { B b = new B(); Page 8 of 15

9 A. Nothing displayed B. "The default constructor of B is invoked" C. "The default constructor of A is invoked""the default constructor of B is invoked" D. "The default constructor of B is invoked""the default constructor of A is invoked" E. "The default constructor of A is invoked" 28 Which of the statements regarding the super keyword is incorrect? A. You can use super to invoke a super class constructor. B. You can use super to invoke a super class method. C. You can use super.super.p to invoke a method in superclass's parent class. D. You cannot invoke a method in superclass's parent class. 29 Which of the following statements are true? A. A method can be overloaded in the same class. B. A method can be overridden in the same class. C. If a method overloads another method, these two methods must have the same signature. D. If a method overrides another method, these two methods must have the same signature. E. A method in a subclass can overload a method in the superclass. 30 What is the output of the following code? new Person().printPerson(); new Student().printPerson(); class Student extends Person { public String getinfo() { return "Student"; class Person { public String getinfo() { return "Person"; public void printperson() { System.out.println(getInfo()); A. Person Person B. Person Student C. Stduent Student D. Student Person 31 Which of the following statements is false? Page 9 of 15

10 A. A public class can be accessed by a class from a different package. B. A private method cannot be accessed by a class in a different package. C. A protected method can be accessed by a subclass in a different package. D. A method with no visibility modifier can be accessed by a class in a different package. 32 are referred to as heavyweight components. A. AWT components B. Swing components C. GUI components D. Non-GUI components 33 The correct order of the following three statements is. 1. frame.setlocationrelativeto(null); 2. frame.setsize(100, 200); 3. frame.setvisible(true); A B C D Suppose a JFrame uses the GridLayout(0, 2). If you add six buttons to the frame, how many columns are displayed? A. 1 B. 2 C. 3 D creates a color object. A. new Color(0, 0, 0) B. new Color(0, 266, 0) C. new Color(255, 255, 255) D. new Color(1, 2, 3) 36 To add a component c to a JPanel p, use. A. p.add(c) B. p.getcontentpane(c) C. p.insert(c) D. p.append(c) Page 10 of 15

11 37 Which of the following is not an advantage of Java exception handling? A. Java separates exception handling from normal processing tasks. B. Exception handling improves performance. C. Exception handling makes it possible for the caller's caller to handle the exception. D. Exception handling simplifies programming because the error-reporting and error-handling code can be placed at the catch block. 38 Which of the following statements are true? A. You use the keyword throws to declare exceptions in the method heading. B. A method may declare to throw multiple exceptions. C. To throw an exception, use the key word throw. D. If a checked exception occurs in a method, it must be either caught or declared to be thrown from the method. 39 An instance of describes the errors caused by your program and external circumstances. These errors can be caught and handled by your program. A. RuntimeException B. Exception C. Error D. Throwable E. NumberFormatException 40 Which of the following declares an abstract method in an abstract Java class? A. public abstract method(); B. public abstract void method(); C. public void abstract Method(); D. public void method() { E. public abstract void method() { 41 Which of the following statements regarding abstract methods are true? A. Abstract classes have constructors. B. A class that contains abstract methods must be abstract. C. It is possible to declare an abstract class that contains no abstract methods. D. An abstract method cannot be contained in a nonabstract class. E. A data field can be declared abstract. Page 11 of 15

12 42 Show the output of running the class Test in the following code lines: interface A { class C { class B extends D implements A { public class Test extends Thread { B b = new B(); if (b instanceof A) System.out.println("b is an instance of A"); if (b instanceof C) System.out.println("b is an instance of C"); class D extends C { A. Nothing. B. b is an instance of A. C. b is an instance of C. D. b is an instance of A followed by b is an instance of C. 43 Suppose a button jbt is placed in a frame, the coordinate of the button within the content pane of the frame is. A. (jbt.getx(), jbt.gety()) B. (jbt.x, jbt.y) C. cannot be obtained D. (0, 0) 44 You should override the method to draw things on a Swing component. A. repaint() B. update() C. paintcomponent() D. init() 45 Which of the following statements are true? A. You may create a Graphics object using new Graphics(). B. Whenever a GUI component is displayed, its Graphics object is automatically created. C. The paintcomponent method is automatically invoked by the JVM. You should never invoke it directly. D. Invoking repaint() causes paintcomponent to be invoked by the JVM. Page 12 of 15

13 46 Which of the following statements are correct? A. You can set an image on a label, but the image is not resizable. B. You can set an image on a button, but the image is not resizable. C. You can draw an image on a GUI component using the drawimage method in the Graphics object. This image is resizable. 47 Clicking the closing button on the upper-right corner of a frame generates a(n) event. A. ItemEvent B. WindowEvent C. MouseMotionEvent D. ComponentEvent E. ContainerEvent 48 Which of the following statements are true? A. Each event class has a corresponding listener interface. B. The listener object's class must implement the corresponding event-listener interface. C. A source may have multiple listeners. D. The listener object must be registered by the source object. 49 To get the x coordinate of the mouse pointer for the MouseEvent evt, you use. A. evt.getx() B. evt.getpoint().x C. Either A or B D. Neither A nor B 50 Analyze the following code: public class Test implements Runnable { Thread t = new Thread(this); t.start(); public void run() { System.out.println("test"); A. The program does not compile because this cannot be referenced in a static method. B. The program compiles fine, but it does not print anything because t does not invoke the run() method. C. The program compiles and runs fine and displays test on the console. D. None of the above. Page 13 of 15

14 Section II [Total 30] You should attempt all section II (questions 2, 3, and 4) Q(2): write a program that displays a message in a panel, and uses two buttons to move the message on the panel to the left or right as shown in Figure 1. [12 Marks] Q(3): (Creating four fans) Write a program that places four fans in a frame of GridLayout with two rows and two columns, as shown in Figure 2. [12 Marks] Figure 1 Figure 2 Q(4): Write a problem that prompts the user to enter a string and reports whether the string is a palindrome. Note that (palindrome if it reads the same forward and backward). [6 Marks] Page 14 of 15 Good Luck

15 Section I [Total 60] Q(1): Multiple choice questions Section I : Key answer for the multiple choice questions Questions Questions Questions Questions Questions Page 15 of 15

Questions Answer Key Questions Answer Key Questions Answer Key

Questions Answer Key Questions Answer Key Questions Answer Key Benha University Term: 2 nd (2013/2014) Class: 2 nd Year Students Subject: Object Oriented Programming Faculty of Computers & Informatics Date: 26/4/2014 Time: 1 hours Exam: Mid-Term (A) Name:. Status:

More information

Questions Answer Key Questions Answer Key Questions Answer Key

Questions Answer Key Questions Answer Key Questions Answer Key Benha University Term: 2 nd (2013/2014) Class: 2 nd Year Students Subject: Object Oriented Programming Faculty of Computers & Informatics Date: 26/4/2014 Time: 1 hours Exam: Mid-Term (B) Name:. Status:

More information

Chapter 8 Objects and Classes Dr. Essam Halim Date: Page 1

Chapter 8 Objects and Classes Dr. Essam Halim Date: Page 1 Assignment (1) Chapter 8 Objects and Classes Dr. Essam Halim Date: 18-3-2014 Page 1 Section 8.2 Defining Classes for Objects 1 represents an entity in the real world that can be distinctly identified.

More information

Practice for Chapter 11

Practice for Chapter 11 Practice for Chapter 11 MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question. 1) Object-oriented programming allows you to derive new classes from existing

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

CIS 265/506 Exam1 Spring 2012 Prof. V. Matos Exam Last Name First Name:

CIS 265/506 Exam1 Spring 2012 Prof. V. Matos Exam Last Name First Name: CIS 265/506 Exam1 Spring 2012 Prof. V. Matos Exam Last Name First Name: MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question. 1) Suppose x = 1, y = -1,

More information

CS 113 MIDTERM EXAM 2 SPRING 2013

CS 113 MIDTERM EXAM 2 SPRING 2013 CS 113 MIDTERM EXAM 2 SPRING 2013 There are 18 questions on this test. The value of each question is: 1-15 multiple choice (3 pts) 17 coding problem (15 pts) 16, 18 coding problems (20 pts) You may get

More information

Questions Answer Key Questions Answer Key Questions Answer Key

Questions Answer Key Questions Answer Key Questions Answer Key Benha University Term: 2 nd (2013/2014) Class: 2 nd Year Students Subject: Object Oriented Programming Faculty of Computers & Informatics Date: 26/4/2014 Time: 1 hours Exam: Mid-Term (C) Name:. Status:

More information

Objective Questions. BCA Part III Paper XIX (Java Programming) page 1 of 5

Objective Questions. BCA Part III Paper XIX (Java Programming) page 1 of 5 Objective Questions BCA Part III page 1 of 5 1. Java is purely object oriented and provides - a. Abstraction, inheritance b. Encapsulation, polymorphism c. Abstraction, polymorphism d. All of the above

More information

Full download all chapters instantly please go to Solutions Manual, Test Bank site: testbanklive.com

Full download all chapters instantly please go to Solutions Manual, Test Bank site: testbanklive.com Introduction to Java Programming Comprehensive Version 10th Edition Liang Test Bank Full Download: http://testbanklive.com/download/introduction-to-java-programming-comprehensive-version-10th-edition-liang-tes

More information

Date: Dr. Essam Halim

Date: Dr. Essam Halim Assignment (1) Date: 11-2-2013 Dr. Essam Halim Part 1: Chapter 2 Elementary Programming 1 Suppose a Scanner object is created as follows: Scanner input = new Scanner(System.in); What method do you use

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

Practice Questions for Chapter 9

Practice Questions for Chapter 9 Practice Questions for Chapter 9 MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question. 1) An object is an instance of a. 1) A) program B) method C) class

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

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

Final Examination Semester 2 / Year 2010

Final Examination Semester 2 / Year 2010 Southern College Kolej Selatan 南方学院 Final Examination Semester 2 / Year 2010 COURSE : JAVA PROGRAMMING COURSE CODE : PROG1114 TIME : 2 1/2 HOURS DEPARTMENT : COMPUTER SCIENCE LECTURER : LIM PEI GEOK Student

More information

Virtualians.ning.pk. 2 - Java program code is compiled into form called 1. Machine code 2. native Code 3. Byte Code (From Lectuer # 2) 4.

Virtualians.ning.pk. 2 - Java program code is compiled into form called 1. Machine code 2. native Code 3. Byte Code (From Lectuer # 2) 4. 1 - What if the main method is declared as private? 1. The program does not compile 2. The program compiles but does not run 3. The program compiles and runs properly ( From Lectuer # 2) 4. The program

More information

CIS265 - Spring Exam 2 First Name Last Name CSU#

CIS265 - Spring Exam 2 First Name Last Name CSU# CIS265 - Spring 2013 - Exam 2 First Name Last Name CSU# MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question. 1) An instance of describes system errors.

More information

Final Examination Semester 2 / Year 2012

Final Examination Semester 2 / Year 2012 Final Examination Semester 2 / Year 2012 COURSE : JAVA PROGRAMMING COURSE CODE : PROG1114 TIME : 2 1/2 HOURS DEPARTMENT : COMPUTER SCIENCE LECTURER : LIM PEI GEOK Student s ID : Batch No. : Notes to candidates:

More information

public class Test { static int age; public static void main (String args []) { age = age + 1; System.out.println("The age is " + age); }

public class Test { static int age; public static void main (String args []) { age = age + 1; System.out.println(The age is  + age); } Question No :1 What is the correct ordering for the import, class and package declarations when found in a Java class? 1. package, import, class 2. class, import, package 3. import, package, class 4. package,

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

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

1. Which of the following is the correct expression of character 4? a. 4 b. "4" c. '\0004' d. '4'

1. Which of the following is the correct expression of character 4? a. 4 b. 4 c. '\0004' d. '4' Practice questions: 1. Which of the following is the correct expression of character 4? a. 4 b. "4" c. '\0004' d. '4' 2. Will System.out.println((char)4) display 4? a. Yes b. No 3. The expression "Java

More information

Final Examination Semester 2 / Year 2011

Final Examination Semester 2 / Year 2011 Southern College Kolej Selatan 南方学院 Final Examination Semester 2 / Year 2011 COURSE COURSE CODE TIME DEPARTMENT LECTURER : JAVA PROGRAMMING : PROG1114 : 2 1/2 HOURS : COMPUTER SCIENCE : LIM PEI GEOK Student

More information

Come & Join Us at VUSTUDENTS.net

Come & Join Us at VUSTUDENTS.net Come & Join Us at VUSTUDENTS.net For Assignment Solution, GDB, Online Quizzes, Helping Study material, Past Solved Papers, Solved MCQs, Current Papers, E-Books & more. Go to http://www.vustudents.net and

More information

Java for Non Majors. Final Study Guide. April 26, You will have an opportunity to earn 20 extra credit points.

Java for Non Majors. Final Study Guide. April 26, You will have an opportunity to earn 20 extra credit points. Java for Non Majors Final Study Guide April 26, 2017 The test consists of 1. Multiple choice questions 2. Given code, find the output 3. Code writing questions 4. Code debugging question 5. Short answer

More information

B2.52-R3: INTRODUCTION TO OBJECT ORIENTATED PROGRAMMING THROUGH JAVA

B2.52-R3: INTRODUCTION TO OBJECT ORIENTATED PROGRAMMING THROUGH JAVA B2.52-R3: INTRODUCTION TO OBJECT ORIENTATED PROGRAMMING THROUGH JAVA NOTE: 1. There are TWO PARTS in this Module/Paper. PART ONE contains FOUR questions and PART TWO contains FIVE questions. 2. PART ONE

More information

Programming II (CS300)

Programming II (CS300) 1 Programming II (CS300) Chapter 04: Exception Handling MOUNA KACEM mouna@cs.wisc.edu Fall 2018 Creating Classes 2 Introduction Exception Handling Common Exceptions Exceptions with Methods Assertions and

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

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

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

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

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

Full file at

Full file at MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question. 1) Suppose a Scanner object is created as follows: 1) Scanner input = new Scanner(System.in); What

More information

Midterm assessment - MAKEUP Fall 2010

Midterm assessment - MAKEUP Fall 2010 M257 MTA Faculty of Computer Studies Information Technology and Computing Date: /1/2011 Duration: 60 minutes 1-Version 1 M 257: Putting Java to Work Midterm assessment - MAKEUP Fall 2010 Student Name:

More information

UNIVERSITI SAINS MALAYSIA. CIT502 Object-Oriented Programming and Software Engineering

UNIVERSITI SAINS MALAYSIA. CIT502 Object-Oriented Programming and Software Engineering UNIVERSITI SAINS MALAYSIA First Semester Examination Academic Session 2003/2004 September/October 2003 CIT502 Object-Oriented Programming and Software Engineering Duration : 3 hours INSTRUCTION TO CANDIDATE:

More information

Casting -Allows a narrowing assignment by asking the Java compiler to "trust us"

Casting -Allows a narrowing assignment by asking the Java compiler to trust us Primitives Integral types: int, short, long, char, byte Floating point types: double, float Boolean types: boolean -passed by value (copied when returned or passed as actual parameters) Arithmetic Operators:

More information

COMP1008 Exceptions. Runtime Error

COMP1008 Exceptions. Runtime Error Runtime Error COMP1008 Exceptions Unexpected error that terminates a program. Undesirable Not detectable by compiler. Caused by: Errors in the program logic. Unexpected failure of services E.g., file server

More information

Chapter 1: Introduction to Computers, Programs, and Java

Chapter 1: Introduction to Computers, Programs, and Java Chapter 1: Introduction to Computers, Programs, and Java 1. Q: When you compile your program, you receive an error as follows: 2. 3. %javac Welcome.java 4. javac not found 5. 6. What is wrong? 7. A: Two

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

Fundamentals of Object Oriented Programming

Fundamentals of Object Oriented Programming INDIAN INSTITUTE OF TECHNOLOGY ROORKEE Fundamentals of Object Oriented Programming CSN- 103 Dr. R. Balasubramanian Associate Professor Department of Computer Science and Engineering Indian Institute of

More information

CSC Java Programming, Fall Java Data Types and Control Constructs

CSC Java Programming, Fall Java Data Types and Control Constructs CSC 243 - Java Programming, Fall 2016 Java Data Types and Control Constructs Java Types In general, a type is collection of possible values Main categories of Java types: Primitive/built-in Object/Reference

More information

Programming II (CS300)

Programming II (CS300) 1 Programming II (CS300) Chapter 04: Exception Handling MOUNA KACEM mouna@cs.wisc.edu Spring 2018 Creating Classes 2 Introduction Exception Handling Common Exceptions Exceptions with Methods Assertions

More information

Table of Contents. Chapter 1 Getting Started with Java SE 7 1. Chapter 2 Exploring Class Members in Java 15. iii. Introduction of Java SE 7...

Table of Contents. Chapter 1 Getting Started with Java SE 7 1. Chapter 2 Exploring Class Members in Java 15. iii. Introduction of Java SE 7... Table of Contents Chapter 1 Getting Started with Java SE 7 1 Introduction of Java SE 7... 2 Exploring the Features of Java... 3 Exploring Features of Java SE 7... 4 Introducing Java Environment... 5 Explaining

More information

B2.52-R3: INTRODUCTION TO OBJECT-ORIENTED PROGRAMMING THROUGH JAVA

B2.52-R3: INTRODUCTION TO OBJECT-ORIENTED PROGRAMMING THROUGH JAVA B2.52-R3: INTRODUCTION TO OBJECT-ORIENTED PROGRAMMING THROUGH JAVA NOTE: 1. There are TWO PARTS in this Module/Paper. PART ONE contains FOUR questions and PART TWO contains FIVE questions. 2. PART ONE

More information

Midterm Exam CS 251, Intermediate Programming March 12, 2014

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

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

WOSO Source Code (Java)

WOSO Source Code (Java) WOSO 2017 - Source Code (Java) Q 1 - Which of the following is false about String? A. String is immutable. B. String can be created using new operator. C. String is a primary data type. D. None of the

More information

Compaq Interview Questions And Answers

Compaq Interview Questions And Answers Part A: Q1. What are the difference between java and C++? Java adopts byte code whereas C++ does not C++ supports destructor whereas java does not support. Multiple inheritance possible in C++ but not

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

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

CS304- Object Oriented Programming LATEST SOLVED MCQS FROM FINALTERM PAPERS. MC

CS304- Object Oriented Programming LATEST SOLVED MCQS FROM FINALTERM PAPERS. MC CS304- Object Oriented Programming LATEST SOLVED MCQS FROM FINALTERM PAPERS JAN 28,2011 MC100401285 Moaaz.pk@gmail.com Mc100401285@gmail.com PSMD01 FINALTERM EXAMINATION 14 Feb, 2011 CS304- Object Oriented

More information

CLASS DESIGN. Objectives MODULE 4

CLASS DESIGN. Objectives MODULE 4 MODULE 4 CLASS DESIGN Objectives > After completing this lesson, you should be able to do the following: Use access levels: private, protected, default, and public. Override methods Overload constructors

More information

CS 113 PRACTICE FINAL

CS 113 PRACTICE FINAL CS 113 PRACTICE FINAL There are 13 questions on this test. The value of each question is: 1-10 multiple choice (4 pt) 11-13 coding problems (20 pt) You may get partial credit for questions 11-13. If you

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

Selected Questions from by Nageshwara Rao

Selected Questions from  by Nageshwara Rao Selected Questions from http://way2java.com by Nageshwara Rao Swaminathan J Amrita University swaminathanj@am.amrita.edu November 24, 2016 Swaminathan J (Amrita University) way2java.com (Nageshwara Rao)

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

HAS-A Relationship. Association is a relationship where all objects have their own lifecycle and there is no owner.

HAS-A Relationship. Association is a relationship where all objects have their own lifecycle and there is no owner. HAS-A Relationship Association is a relationship where all objects have their own lifecycle and there is no owner. For example, teacher student Aggregation is a specialized form of association where all

More information

15CS45 : OBJECT ORIENTED CONCEPTS

15CS45 : OBJECT ORIENTED CONCEPTS 15CS45 : OBJECT ORIENTED CONCEPTS QUESTION BANK: What do you know about Java? What are the supported platforms by Java Programming Language? List any five features of Java? Why is Java Architectural Neutral?

More information

The JFrame Class Frame Windows GRAPHICAL USER INTERFACES. Five steps to displaying a frame: 1) Construct an object of the JFrame class

The JFrame Class Frame Windows GRAPHICAL USER INTERFACES. Five steps to displaying a frame: 1) Construct an object of the JFrame class CHAPTER GRAPHICAL USER INTERFACES 10 Slides by Donald W. Smith TechNeTrain.com Final Draft 10/30/11 10.1 Frame Windows Java provides classes to create graphical applications that can run on any major graphical

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

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

CS 11 java track: lecture 3

CS 11 java track: lecture 3 CS 11 java track: lecture 3 This week: documentation (javadoc) exception handling more on object-oriented programming (OOP) inheritance and polymorphism abstract classes and interfaces graphical user interfaces

More information

UNIT 3 ARRAYS, RECURSION, AND COMPLEXITY CHAPTER 11 CLASSES CONTINUED

UNIT 3 ARRAYS, RECURSION, AND COMPLEXITY CHAPTER 11 CLASSES CONTINUED UNIT 3 ARRAYS, RECURSION, AND COMPLEXITY CHAPTER 11 CLASSES CONTINUED EXERCISE 11.1 1. static public final int DEFAULT_NUM_SCORES = 3; 2. Java allocates a separate set of memory cells in each instance

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

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

3.Constructors and Destructors. Develop cpp program to implement constructor and destructor.

3.Constructors and Destructors. Develop cpp program to implement constructor and destructor. 3.Constructors and Destructors Develop cpp program to implement constructor and destructor. Constructors A constructor is a special member function whose task is to initialize the objects of its class.

More information

SELF-STUDY. Glossary

SELF-STUDY. Glossary SELF-STUDY 231 Glossary HTML (Hyper Text Markup Language - the language used to code web pages) tags used to embed an applet. abstract A class or method that is incompletely defined,

More information

Object Oriented Programming with Java. Unit-1

Object Oriented Programming with Java. Unit-1 CEB430 Object Oriented Programming with Java Unit-1 PART A 1. Define Object Oriented Programming. 2. Define Objects. 3. What are the features of Object oriented programming. 4. Define Encapsulation and

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

CS 180 Final Exam Review 12/(11, 12)/08

CS 180 Final Exam Review 12/(11, 12)/08 CS 180 Final Exam Review 12/(11, 12)/08 Announcements Final Exam Thursday, 18 th December, 10:20 am 12:20 pm in PHYS 112 Format 30 multiple choice questions 5 programming questions More stress on topics

More information

APCS Unit 5 Exam. Assuming all four classes have a default constructor, which of the following statements would result in an error from the compiler?

APCS Unit 5 Exam. Assuming all four classes have a default constructor, which of the following statements would result in an error from the compiler? APCS Unit 5 Exam Name 1. Suppose we had a superclass called Fruit. The subclasses of this superclass are Apple, Orange, and Banana. Consider the following reference variable declarations. Fruit f; Banana

More information

CS/B.TECH/CSE(OLD)/SEM-6/CS-605/2012 OBJECT ORIENTED PROGRAMMING. Time Allotted : 3 Hours Full Marks : 70

CS/B.TECH/CSE(OLD)/SEM-6/CS-605/2012 OBJECT ORIENTED PROGRAMMING. Time Allotted : 3 Hours Full Marks : 70 CS/B.TECH/CSE(OLD)/SEM-6/CS-605/2012 2012 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

S.E. Sem. III [CMPN] Object Oriented Programming Methodology

S.E. Sem. III [CMPN] Object Oriented Programming Methodology S.E. Sem. III [CMPN] Object Oriented Programming Methodology Time : 3 Hrs.] Prelim Question Paper Solution [Marks : 80 Q.1(a) Write a program to calculate GCD of two numbers in java. [5] (A) import java.util.*;

More information

CS 209 Programming in Java #10 Exception Handling

CS 209 Programming in Java #10 Exception Handling CS 209 Programming in Java #10 Exception Handling Textbook Chapter 15 Spring, 2006 Instructor: J.G. Neal 1 Topics What is an Exception? Exception Handling Fundamentals Errors and Exceptions The try-catch-finally

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

Lecture 28. Exceptions and Inner Classes. Goals. We are going to talk in more detail about two advanced Java features:

Lecture 28. Exceptions and Inner Classes. Goals. We are going to talk in more detail about two advanced Java features: Lecture 28 Exceptions and Inner Classes Goals We are going to talk in more detail about two advanced Java features: Exceptions supply Java s error handling mechanism. Inner classes ease the overhead of

More information

More About Objects. Zheng-Liang Lu Java Programming 255 / 282

More About Objects. Zheng-Liang Lu Java Programming 255 / 282 More About Objects Inheritance: passing down states and behaviors from the parents to their children. Interfaces: requiring objects for the demanding methods which are exposed to the outside world. Polymorphism

More information

Inheritance. Chapter 7. Chapter 7 1

Inheritance. Chapter 7. Chapter 7 1 Inheritance Chapter 7 Chapter 7 1 Introduction to Inheritance Inheritance allows us to define a general class and then define more specialized classes simply by adding new details to the more general class

More information

Full file at

Full file at MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question. 1) 25 % 1 is. 1) A) 2 B) 1 C) 0 D) 4 E) 3 2) Which of the following expressions will yield 0.5? (choose

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

More on Objects in JAVA TM

More on Objects in JAVA TM More on Objects in JAVA TM Inheritance : Definition: A subclass is a class that extends another class. A subclass inherits state and behavior from all of its ancestors. The term superclass refers to a

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

POLYTECHNIC OF NAMIBIA SCHOOL OF COMPUTING AND INFORMATICS DEPARTMENT OF COMPUTER SCIENCE

POLYTECHNIC OF NAMIBIA SCHOOL OF COMPUTING AND INFORMATICS DEPARTMENT OF COMPUTER SCIENCE POLYTECHNIC OF NAMIBIA SCHOOL OF COMPUTING AND INFORMATICS DEPARTMENT OF COMPUTER SCIENCE COURSE NAME: OBJECT ORIENTED PROGRAMMING COURSE CODE: OOP521S NQF LEVEL: 6 DATE: NOVEMBER 2015 DURATION: 2 HOURS

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

CREATED BY: Muhammad Bilal Arslan Ahmad Shaad. JAVA Chapter No 5. Instructor: Muhammad Naveed

CREATED BY: Muhammad Bilal Arslan Ahmad Shaad. JAVA Chapter No 5. Instructor: Muhammad Naveed CREATED BY: Muhammad Bilal Arslan Ahmad Shaad JAVA Chapter No 5 Instructor: Muhammad Naveed Muhammad Bilal Arslan Ahmad Shaad Chapter No 5 Object Oriented Programming Q: Explain subclass and inheritance?

More information

Chapter 14. Exception Handling and Event Handling

Chapter 14. Exception Handling and Event Handling Chapter 14 Exception Handling and Event Handling Chapter 14 Topics Introduction to Exception Handling Exception Handling in Ada Exception Handling in C++ Exception Handling in Java Introduction to Event

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

Computer Programming, I. Laboratory Manual. Final Exam Solution

Computer Programming, I. Laboratory Manual. Final Exam Solution Think Twice Code Once The Islamic University of Gaza Engineering Faculty Department of Computer Engineering Fall 2017 ECOM 2005 Khaleel I. Shaheen Computer Programming, I Laboratory Manual Final Exam Solution

More information

COMP 202. More on OO. CONTENTS: static revisited this reference class dependencies method parameters variable scope method overloading

COMP 202. More on OO. CONTENTS: static revisited this reference class dependencies method parameters variable scope method overloading COMP 202 CONTENTS: static revisited this reference class dependencies method parameters variable scope method overloading More on OO COMP 202 Objects 3 1 Static member variables So far: Member variables

More information

Object-Oriented Concepts

Object-Oriented Concepts JAC444 - Lecture 3 Object-Oriented Concepts Segment 2 Inheritance 1 Classes Segment 2 Inheritance In this segment you will be learning about: Inheritance Overriding Final Methods and Classes Implementing

More information

CS1150 Principles of Computer Science Objects and Classes

CS1150 Principles of Computer Science Objects and Classes CS1150 Principles of Computer Science Objects and Classes Yanyan Zhuang Department of Computer Science http://www.cs.uccs.edu/~yzhuang CS1150 UC. Colorado Springs Object-Oriented Thinking Chapters 1-8

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

Arrays Classes & Methods, Inheritance

Arrays Classes & Methods, Inheritance Course Name: Advanced Java Lecture 4 Topics to be covered Arrays Classes & Methods, Inheritance INTRODUCTION TO ARRAYS The following variable declarations each allocate enough storage to hold one value

More information

Final Exam CS 251, Intermediate Programming December 13, 2017

Final Exam CS 251, Intermediate Programming December 13, 2017 Final Exam CS 251, Intermediate Programming December 13, 2017 Name: NetID: Answer all questions in the space provided. Write clearly and legibly, you will not get credit for illegible or incomprehensible

More information

Java for Non Majors Spring 2018

Java for Non Majors Spring 2018 Java for Non Majors Spring 2018 Final Study Guide The test consists of 1. Multiple choice questions - 15 x 2 = 30 points 2. Given code, find the output - 3 x 5 = 15 points 3. Short answer questions - 3

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

Exception-Handling Overview

Exception-Handling Overview م.عبد الغني أبوجبل Exception Handling No matter how good a programmer you are, you cannot control everything. Things can go wrong. Very wrong. When you write a risky method, you need code to handle the

More information

Chapter 5 Object-Oriented Programming

Chapter 5 Object-Oriented Programming Chapter 5 Object-Oriented Programming Develop code that implements tight encapsulation, loose coupling, and high cohesion Develop code that demonstrates the use of polymorphism Develop code that declares

More information

Inheritance. One class inherits from another if it describes a specialized subset of objects Terminology:

Inheritance. One class inherits from another if it describes a specialized subset of objects Terminology: Inheritance 1 Inheritance One class inherits from another if it describes a specialized subset of objects Terminology: the class that inherits is called a child class or subclass the class that is inherited

More information