Module Contact: Dr Anthony J. Bagnall, CMP Copyright of the University of East Anglia Version 1

Similar documents
PART-A Questions. 2. How does an enumerated statement differ from a typedef statement?

Java Interview Questions and Answers

Embedded Programming in C/C++: Lesson-1: Programming Elements and Programming in C

I PUC - Computer Science. Practical s Syllabus. Contents

Classes and Objects in Java Constructors. In creating objects of the type Fraction, we have used statements similar to the following:

1.4 Arrays Introduction to Programming in Java: An Interdisciplinary Approach Robert Sedgewick and Kevin Wayne Copyright /6/11 12:33 PM!

Homework 2 Solutions

CS 111 Classes I 1. Software Organization View to this point:

KITES TECHNOLOGY COURSE MODULE (C, C++, DS)

Glossary of Object Oriented Terms

Java SE 8 Programming

Answers to Review Questions Chapter 7

Pemrograman Dasar. Basic Elements Of Java

CS 341 Software Design Homework 5 Identifying Classes, UML Diagrams Due: Oct. 22, 11:30 PM

El Dorado Union High School District Educational Services

Chapter 2: Elements of Java

How To Port A Program To Dynamic C (C) (C-Based) (Program) (For A Non Portable Program) (Un Portable) (Permanent) (Non Portable) C-Based (Programs) (Powerpoint)

Object Oriented Software Design II

Fundamentals of Java Programming

PROBLEM SOLVING SEVENTH EDITION WALTER SAVITCH UNIVERSITY OF CALIFORNIA, SAN DIEGO CONTRIBUTOR KENRICK MOCK UNIVERSITY OF ALASKA, ANCHORAGE PEARSON

Lesson 1. Basics of Probability. Principles of Mathematics 12: Explained! 314

7.1 Our Current Model

Fundamentals of Probability

CORBA Programming with TAOX11. The C++11 CORBA Implementation

: provid.ir

The C Programming Language course syllabus associate level

Binary storage of graphs and related data

Poker. 10,Jack,Queen,King,Ace. 10, Jack, Queen, King, Ace of the same suit Five consecutive ranks of the same suit that is not a 5,6,7,8,9

Caml Virtual Machine File & data formats Document version: 1.4

Problem 1. CS 61b Summer 2005 Homework #2 Due July 5th at the beginning of class

Moving from CS 61A Scheme to CS 61B Java

CmpSci 187: Programming with Data Structures Spring 2015

Informatica e Sistemi in Tempo Reale

VB.NET Programming Fundamentals

Java the UML Way: Integrating Object-Oriented Design and Programming

sqlite driver manual

Name: Class: Date: 9. The compiler ignores all comments they are there strictly for the convenience of anyone reading the program.

13 Classes & Objects with Constructors/Destructors

Java SE 7 Programming

Java SE 7 Programming

ALLIED PAPER : DISCRETE MATHEMATICS (for B.Sc. Computer Technology & B.Sc. Multimedia and Web Technology)

Sources: On the Web: Slides will be available on:

Chapter 6: Programming Languages

Multichoice Quetions 1. Atributes a. are listed in the second part of the class box b. its time is preceded by a colon. c. its default value is

Lecture 3. Arrays. Name of array. c[0] c[1] c[2] c[3] c[4] c[5] c[6] c[7] c[8] c[9] c[10] c[11] Position number of the element within array c

C++ Programming Language

12-6 Write a recursive definition of a valid Java identifier (see chapter 2).

Getting Started with the Internet Communications Engine

TECHNOLOGY Computer Programming II Grade: 9-12 Standard 2: Technology and Society Interaction

Introduction to C++ Introduction to C++ Week 7 Dr Alex Martin 2013 Slide 1

C++ INTERVIEW QUESTIONS

Cohort: BCA/07B/PT - BCA/06/PT - BCNS/06/FT - BCNS/05/FT - BIS/06/FT - BIS/05/FT - BSE/05/FT - BSE/04/PT-BSE/06/FT

5 Arrays and Pointers

Masters programmes in Computer Science and Information Systems. Object-Oriented Design and Programming. Sample module entry test xxth December 2013

An Overview of Java. overview-1

AP Computer Science Java Subset

First Java Programs. V. Paúl Pauca. CSC 111D Fall, Department of Computer Science Wake Forest University. Introduction to Computer Science

An Incomplete C++ Primer. University of Wyoming MA 5310

10CS35: Data Structures Using C

Module Contact: Dr. Beatriz de la Iglesia, CMP Copyright of the University of East Anglia Version 1

public static void main(string[] args) { System.out.println("hello, world"); } }

Pseudo code Tutorial and Exercises Teacher s Version

Chapter 4 OOPS WITH C++ Sahaj Computer Solutions

Project 2: Bejeweled

Operator Overloading. Lecture 8. Operator Overloading. Running Example: Complex Numbers. Syntax. What can be overloaded. Syntax -- First Example

C++FA 5.1 PRACTICE MID-TERM EXAM

C Programming. for Embedded Microcontrollers. Warwick A. Smith. Postbus 11. Elektor International Media BV. 6114ZG Susteren The Netherlands

(b) You draw two balls from an urn and track the colors. When you start, it contains three blue balls and one red ball.

JAVA - QUICK GUIDE. Java SE is freely available from the link Download Java. So you download a version based on your operating system.

ASCII Encoding. The char Type. Manipulating Characters. Manipulating Characters

language 1 (source) compiler language 2 (target) Figure 1: Compiling a program

The Set Data Model CHAPTER What This Chapter Is About

Syntax Check of Embedded SQL in C++ with Proto

Base Conversion written by Cathy Saxton

Java SE 7 Programming

Course Name: ADVANCE COURSE IN SOFTWARE DEVELOPMENT (Specialization:.Net Technologies)

Course Title: Software Development

1. The memory address of the first element of an array is called A. floor address B. foundation addressc. first address D.

J a v a Quiz (Unit 3, Test 0 Practice)

Embedded Systems. Review of ANSI C Topics. A Review of ANSI C and Considerations for Embedded C Programming. Basic features of C

CS1002: COMPUTER SCIENCE OO MODELLING & DESIGN: WEEK 5

C++ Language Tutorial

Part 3: GridWorld Classes and Interfaces

The Sun Certified Associate for the Java Platform, Standard Edition, Exam Version 1.0

Object-Oriented Design Lecture 4 CSU 370 Fall 2007 (Pucella) Tuesday, Sep 18, 2007

Basics of I/O Streams and File I/O

IS0020 Program Design and Software Tools Midterm, Feb 24, Instruction

Java (12 Weeks) Introduction to Java Programming Language

Introduction to Distributed Computing using CORBA

Java Classes. GEEN163 Introduction to Computer Programming

Algorithms, Flowcharts & Program Design. ComPro

Ready, Set, Go! Math Games for Serious Minds

POKER LOTTO LOTTERY GAME CONDITIONS These Game Conditions apply, until amended or revised, to the POKER LOTTO lottery game.

UNDERGROUND TONK LEAGUE

Debugging. Common Semantic Errors ESE112. Java Library. It is highly unlikely that you will write code that will work on the first go

1 Abstract Data Types Information Hiding

PES Institute of Technology-BSC QUESTION BANK

e ag u g an L g ter lvin v E ram Neal G g ro va P Ja

SECTION 10-5 Multiplication Principle, Permutations, and Combinations

Transcription:

UNIVERSITY OF EAST ANGLIA School of Computing Sciences Main Series UG Examination 2015/16 PROGRAMMING 2 CMP-5015Y Time allowed: 2 hours Answer four questions. All questions carry equal weight. Notes are not permitted in this examination. Do not turn over until you are told to do so by the Invigilator. CMP-5015Y Module Contact: Dr Anthony J. Bagnall, CMP Copyright of the University of East Anglia Version 1

Page 2 1. (a) Describe, with the aid of diagrams, the three types of structure commonly employed in parallel computing systems and give examples of when each structure is commonly used. (b) Explain the difference between a process and a thread. (c) Describe, with the aid of code segment examples, how you define a class that can be threaded and how an object of that class could be run in its own thread. (d) Describe, with code examples, different ways of claiming a monitor lock in Java with the keyword synchronized. 2. (a) What is an enum type in Java? Give an example of defining and declaring a simple enum type in Java. (b) How do Java enum types differ from C++ enum types? (c) What are the benefits of using enum in Java? [5 marks] [5 marks] (d) Write a Java class Card. Each card should have a suit (clubs, diamonds, hearts or spades) and a rank (two, three, four, five, six, seven, eight, nine, ten, jack, queen, king, ace). You should model this with enum types. Include a constructor to initialise a card based on arguments passed. (e) Write a Java class Deck that contains a List of Card objects. Include in the class Deck a constructor that creates the List of Card objects where each card has a unique suit and rank.

Page 3 3. (a) In the context of Java, what is meant by Serialization? [2 marks] (b) Explain, with simple code segment examples, how basic serialization is implemented in Java. [6 marks] (c) What is a transient variable? Why would we make a variable transient? (d) Explain, with code examples, the difference between the implementation of two dimensional arrays in Java and C++. (e) In the context of Java, what is meant by Reflection? Explain, with code segment examples, how it can be used. (f) What is an Exception in Java? What are the benefits of using Exceptions? [6 marks] 4. (a) The Fibonacci series is a series of integers starting 0, 1, 1, 2, 3, 5, 8, 13, 21, 34,.... Each element of the series is the sum of the two preceding elements. Write a C++ function that returns a dynamically allocated array of unsigned integers containing the first 1024 elements of the series. (b) Describe the differences between inheritance in the C++ programming language and in Java. (c) Write a C++ template function, called withinrange, with three parameters of the same type, that returns true if the first argument is greater than or equal to the second, but less than or equal the third. TURN OVER

Page 4 5. (a) A palindrome is a sequence of characters that reads the same backward or forward, for example kayak. Write a C function that takes a null terminated string as an argument and returns a value representing true if the string is palindromic and a value interpreted as false otherwise. The function must not use any functions declared in the string library header string.h. (b) What are the types of the variables created in each of the following declarations? Where the declaration will not compile, explain why this is the case. Where the declaration will only compile if certain conditions are met, state those conditions. (i) int n = 10L; (ii) struct Foo *sp = &s; (iii) double wombat[10] = {0.1, 0.2, 0.3, 0.4}; (iv) int *do = &n; (v) int* const p = &n; (c) Write a C code fragment that creates a file called "factorial.txt" containing a table of the factorials of the integers from 0 to 10. The factorial of a positive integer n, denoted n!, is the product of all the integers 1 to n, i.e. n! = n (n 1)... 3 2 1. The factorial of zero, is defined to as 0! = 1. The table should have two columns, the first giving n and the second n!.

Page 5 6. (a) Write a C++ class representing a date, described by the day of month, the month of year and the year. The class should include appropriate constructors, accessor methods and overloaded operators supporting the use of stream-based I/O, and the overloading of the binary subtraction operator, such that subtracting one Date object from another gives an integer representing the number of days separating the two dates. A full set of relational operators should also be provided. For convenience, assume leap years do not exist and that February has 28 days, April, June, September, and November each have 30 days and January, March, May, July, August October and December each consist of 31 days. [30 marks] END OF PAPER