University of Palestine. Mid Exam Total Grade: 100

Similar documents
Practice Questions for Chapter 9

ESC101 : Fundamental of Computing

Q1 Q2 Q3 Q4 Q5 Total 1 * 7 1 * 5 20 * * Final marks Marks First Question

1.00 Introduction to Computers and Engineering Problem Solving. Quiz 1 March 7, 2003

1. What is the difference between a compiler and an interpreter? Also, discuss Java s method.

Sequence structure. The computer executes java statements one after the other in the order in which they are written. Total = total +grade;

CS18000: Problem Solving And Object-Oriented Programming

Questions Answer Key Questions Answer Key Questions Answer Key

Computer Programming, I. Laboratory Manual. Final Exam Solution

Fall CS 101: Test 2 Name UVA ID. Grading. Page 1 / 4. Page3 / 20. Page 4 / 13. Page 5 / 10. Page 6 / 26. Page 7 / 17.

CSE 201 JAVA PROGRAMMING I. Copyright 2016 by Smart Coding School

CMPS 11 Intermediate Programming Midterm 2 Review Problems

COMP102: Test. 18 April, 2005

CSCI 135 Exam #0 Fundamentals of Computer Science I Fall 2012

Arrays. 1 Index mapping

Exam 2. Programming I (CPCS 202) Instructor: M. G. Abbas Malik. Total Marks: 40 Obtained Marks:

CSCI 135 Exam #1 Fundamentals of Computer Science I Fall 2014

Basic computer skills such as using Windows, Internet Explorer, and Microsoft Word. Chapter 1 Introduction to Computers, Programs, and Java

JAVA OPERATORS GENERAL

Questions Answer Key Questions Answer Key Questions Answer Key

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

Introduction to Java

COMPUTER APPLICATIONS

Questions Answer Key Questions Answer Key Questions Answer Key

Computação I. Exercises. Leonardo Vanneschi NOVA IMS, Universidade Nova de Lisboa. Leonardo Vanneschi Computação I NOVA IMS

Birkbeck (University of London) Software and Programming 1 In-class Test Mar 2018

1.00 Introduction to Computers and Engineering Problem Solving Quiz 1 March 4, 2005

CMPS 12A Introduction to Programming Midterm 2 Review Problems

COMP-202. Recursion. COMP Recursion, 2011 Jörg Kienzle and others

CS180. Exam 1 Review

C212 Early Evaluation Exam Mon Feb Name: Please provide brief (common sense) justifications with your answers below.

Practice Questions for Final Exam: Advanced Java Concepts + Additional Questions from Earlier Parts of the Course

Computer Science is...

CIS October 19, 2017

Class, Variable, Constructor, Object, Method Questions

CLASS DESIGN. Objectives MODULE 4

CMPS 12A - Winter 2002 Final Exam A March 16, Name: ID:

COS 126 General Computer Science Spring Written Exam 1

CS 113 MIDTERM EXAM 2 SPRING 2013

CIS 1068 Program Design and Abstraction Spring2016 Midterm Exam 1. Name SOLUTION

CIS 120 Programming Languages and Techniques. Midterm II. November 12, 2010

CS101 Part 2: Practice Questions Algorithms on Arrays, Classes and Objects, String Class, Stack Class

CS S-08 Arrays and Midterm Review 1

CIS 1068 Design and Abstraction Spring 2017 Midterm 1a

CS212 Midterm. 1. Read the following code fragments and answer the questions.

JAVA Programming Language Homework II Student ID: Name:

Selenium Class 9 - Java Operators

CS18000: Programming I

ANSWERS. Birkbeck (University of London) Software and Programming 1 In-class Test Feb Student Name Student Number. Answer all questions

Lecture 5: Methods CS2301

ANSWERS. Birkbeck (University of London) Software and Programming 1 In-class Test Feb Student Name Student Number. Answer all questions

CIS 120 Programming Languages and Techniques. Midterm II. November 12, Answer key

CMPS 12A Winter 2006 Prof. Scott A. Brandt Final Exam, March 21, Name:

JAVA PROGRAMMING LAB. ABSTRACT In this Lab you will learn to define and invoke void and return java methods

Solutions Manual. Data Structures and Algorithms in Java, 5th edition International Student Version. M. T. Goodrich and R.

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

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

CS5000: Foundations of Programming. Mingon Kang, PhD Computer Science, Kennesaw State University

(A) 99 ** (B) 100 (C) 101 (D) 100 initial integers plus any additional integers required during program execution

University of Massachusetts Amherst, Electrical and Computer Engineering

Selected Questions from by Nageshwara Rao

1 Short Answer (10 Points Each)

Unit 10: Sorting/Searching/Recursion

Methods. Bok, Jong Soon

CS171:Introduction to Computer Science II

COE318 Lecture Notes Week 4 (Sept 26, 2011)

Birkbeck (University of London) Software and Programming 1 In-class Test Mar Answer ALL Questions

Place your name tag here

Java provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following groups:

Distributed Systems Recitation 1. Tamim Jabban

Programming Problems 22nd Annual Computer Science Programming Contest

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

Chapter 1: Introduction to Computers, Programs, and Java

Java and OOP. Part 2 Classes and objects

Last Name: Circle One: OCW Non-OCW

Exam Duration: 2hrs and 30min Software Design

Use the scantron sheet to enter the answer to questions (pages 1-6)

CS141 Programming Assignment #5

Unit 4: Classes and Objects Notes

CIS March 1, 2018

Chapter 5 Control Statements: Part 2 Section 5.2 Essentials of Counter-Controlled Repetition

User-built data types Mutable and immutable data

Announcements. PS 3 is due Thursday, 10/6. Midterm Exam 1: 10/14 (Fri), 9:00am-10:53am

CS 231 Data Structures and Algorithms Fall Binary Search Trees Lecture 23 October 29, Prof. Zadia Codabux

Arrays. COMS W1007 Introduction to Computer Science. Christopher Conway 10 June 2003

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

Arrays. Arrays. Wolfgang Schreiner Research Institute for Symbolic Computation (RISC) Johannes Kepler University, Linz, Austria

CSEN 202: Introduction to Computer Programming Spring term Final Exam

CS111: PROGRAMMING LANGUAGE II

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

MIDTERM REVIEW. midterminformation.htm

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)

COMPUTER APPLICATIONS

APCS Semester #1 Final Exam Practice Problems

CPSC 219 Extra review and solutions

Announcements. Lab 03 inbase late submissions Midterm #1 Friday. Project 2 is posted. Covers everything through basics of OOP

CS170 Introduction to Computer Science Midterm 2

BSc. (Hons.) Software Engineering. Examinations for / Semester 2

CSC 240 Computer Science III Spring 2018 Midterm Exam. Name

1. Find the output of following java program. class MainClass { public static void main (String arg[])

Transcription:

First Question No. of Branches (5) A) Choose the correct answer: 1. If we type: system.out.println( a ); in the main() method, what will be the result? int a=12; //in the global space... void f() { int a = 8; a = a/2; a. Other b. 12 c. 4 d. 0 40 Marks 2. What is the value of a[99] after these statements? int[] a = new int[100]; a[0] = 1; for (int i = 1; i < a.length; i++) a[i] = 1 - a[i-1]; (a) -2 (b) -1 (c) 0 (d) 1 (e) 2 B) Find and correct the error in each of the following program segments: a) final int MAX = 10; MAX = 15; b) Assume int b[] = new int[ 10 ]; for ( int i = 0; i <= b.length; i++ ) b[ i ] = 1; c) Assume int a[][] = { { 1, 2, { 3, 4 ; a[ 1, 1 ] = 5; d) public class C { private int p; public C( ) { System.out.println("C's no-arg constructor invoked"); this(0); public C(int p) { p = p; public void setp(int p) { p = p; 1/7

C )What will be the return value if we call f(7); int f (int v) { if ((v = = 1) (v = = 0)) return 1; else if ((v%2) = = 0) return f(v/2) + 2; else return f(v-1) + 3; D) What is the output of the following program? public class Foo { private static int i = 0; private static int j = 0; public static void main(string[] args) { int i = 2; int k = 3; { int j = 3; System.out.println("i + j is " + i + j); k = i + j; System.out.println("k is " + k); System.out.println("j is " + j); E) Read the following code: Can you run the code without errors? if no find the error and correct it. What is the output of the code? And what is the relation between class A and B? class A { int data; public void f(int arg) { data = arg; public int g() { return data; Public class B { A x; public class Test{ public static void main(string args[]) { B obj; obj.x.f(20); system.out.println( obj.x.g()); system.out.println (obj.g()); 2/7

Second Question No. of Branches (5) 40 marks 1. What is reusability? How do you achieve this in Java? 2. What is overloading? Overload a method called Sum which can take two or three integers and returns their summation. Write just two lines to call each of them with values. 3. Write a recursive function called SumRange that takes two arguments n and m and returns the sum of all integers from n to m, both inclusive. 3/7

4. Write a method called search that takes two parameters a 2D array of integers and an integer value n. It should return true if the element n is found in the array, false otherwise. 5. What is the difference between call by value and call by reference? Give example for each? 4/7

Third Question: No. of Branches (2) 20 Marks The following tree shows a general Person class with its main properties. Try to understand it carefully and then answer the following questions. A Person has a Job : Person Job { role; salary; id Person {name, age Use Composition Name Age Job Role Salary ID 1- Write a complete object oriented JAVA program to implement the above tree, 2- The Person class might have the following operations: A constructor Person Data Input operation (Set, Get) Person Total Salary for one year (calculation operation.) Person Information Display operation. (Outut) 3- The main program might: Create a Person object; Apply all operations for the object. 5/7

Good Luck 6/7

7/7