SCHOOL OF COMPUTING, ENGINEERING AND MATHEMATICS SEMESTER 2 EXAMINATIONS 2014/2015 CI101/CI101H. Programming
|
|
- Karin Merritt
- 5 years ago
- Views:
Transcription
1 s SCHOOL OF COMPUTING, ENGINEERING AND MATHEMATICS SEMESTER 2 EXAMINATIONS 2014/2015 CI101/CI101H Programming Time allowed: THREE hours Answer: ALL questions Items permitted: Items supplied: There is no restriction on the paper-based items or items on a USB flash drive that the student may take into the examination. None CI101_SEM2_2014/2015 Page 1 of 22 Printing date: 23/09/2015
2 Section A Section A carries 50 marks in total. Use the application provided to record the answer for each multiple choice question (Question 1 Question 20) in section A of this exam paper. Remember to fill in your student number in the box provided for this (Highlighted initially with a reddish background) before exiting from the application. Each question in Section A is worth 2.5 marks. Section A carries 50 marks in total. There is no penalty for answering a question wrongly. Question 1 class Main public static void main( String args[] ) String message = " %s"; System.out.printf( "Message %s" + message, "for today", "warm" ); When executed the above Java application will print: (a) Message %s %s for today warm (b) Message for today (c) Message for today warm (d) for today warm CI101_SEM2_2014/2015 Page 2 of 22 Printing date: 23/09/2015
3 Question 2 class Main public static void main( String args[] ) int value = 5; value = 7 / 2; System.out.println( value ); value = 7 / 3; System.out.println( value ); value = 7 % 2; System.out.println( value ); value = 7 % 7; System.out.println( value ); When executed the above Java application will: (a) The number 2 twice. (b) The number 1 twice. (c) The number 0 twice. (d) 4 different numbers in descending order. CI101_SEM2_2014/2015 Page 3 of 22 Printing date: 23/09/2015
4 Question 3 class Main public static void main( String args[] ) int large = 100; int small = 1; if ( large >= small ) System.out.println("OK"); if ( large <= large ) System.out.println("OK"); if ( small >= large ) System.out.println("OK"); if ( small <= large ) System.out.println("OK"); if ( small <= large && small >= large ) System.out.println("OK"); When executed the above Java application will: (a) (b) (c) (d) Print OK 4 times. Print OK 3 times. Print OK 2 times. Print OK once. CI101_SEM2_2014/2015 Page 4 of 22 Printing date: 23/09/2015
5 Question 4 class Main public static void main ( String args[] ) int rooms[] = new int[5]; // Line A System.out.println( rooms[0] ); int rooms[] = new int[1]; System.out.println( rooms[0] ); int rooms[] = 0,1,2 ; System.out.println( rooms[0] ); int rooms[]; System.out.println( rooms[0] ); // Line B // Line C // Line D The above Java application will fail to compile because: (a) There are multiple declarations of rooms, lines A, B, C and D. (b) Line C is not valid Java. (c) Line D is not valid Java. (d) The compiler will detect that the declaration of rooms in Line D may not have been initialised. CI101_SEM2_2014/2015 Page 5 of 22 Printing date: 23/09/2015
6 Question 5 interface Animal public String speak(); public String name(); public int age(); class Dog implements Animal private String name = ""; private int age = 0; public Dog( String nameis, int ageis ) name = nameis; age = ageis; public String speak() return "bark"; public String name() return this.name; public int age() return this.age; For the above fragment of a Java application, which of the following statements would be true? (a) Animal pet = new Dog(); Would be a valid declaration at an appropriate point in a later part of the Java application. (b) Animal pet = new Dog( "Cleo", 4 ); Would be a valid declaration at an appropriate point in a later part of the Java application. (c) Animal pet = new Animal( "Cleo", 4 ); Would be a valid declaration at an appropriate point in a later part of the Java application. (d) All of the above declarations (a), (b) or (c) would be an invalid declaration at an appropriate point in a later part of the Java application. CI101_SEM2_2014/2015 Page 6 of 22 Printing date: 23/09/2015
7 Question 6 class Main static int value = 10; public static void main( String args[] ) int value = 0; for ( int i=1; i<=2; i++ ) value += i; System.out.println( value ); After executing the above Java application the result printed would be: (a) 1 (b) 2 (c) 3 (d) 10 Question 7 Which of the following declarations is NOT valid inside a Java class? (a) public int start(int n) return n>1? start(n-1) : 1; (b) private final int question = 7; (c) public int answer = 7; (d) boolean this = true && false; CI101_SEM2_2014/2015 Page 7 of 22 Printing date: 23/09/2015
8 Question 8 When combined with other Java code the following statement: System.out.printf( "[%s] is [%d] characters long\n", "Brighton", "Brighton".length() ); when executed will print: (a) (b) (c) (d) [Brighton] is [8] characters long [Brighton ] is [8] characters long [ Brighton] is [8] characters long A Java run time error message Question 9 class Main public static void main( String args[] ) int numbers[] = new int[4]; numbers[0] = 0; numbers[1] = 1; for ( int i=2; i< numbers.length; i++ ) numbers[i] = numbers[i-1] + numbers[i-2]; int sum = 0; for ( int val: numbers ) sum += val; System.out.println( sum ); When executed the above Java application will print: (a) 1 (b) 2 (c) 4 (d) 8 CI101_SEM2_2014/2015 Page 8 of 22 Printing date: 23/09/2015
9 Question 10 class Main public static void main (String args[] ) char name[] = 'H', 'A', 'L' ; for ( char c: name ) char nc = (char) ( ((int) c) + 1 ); System.out.print( nc ); System.out.println(); When executed the above Java application will print: (a) (b) (c) (d) HAL G K IBM A Java run time error message CI101_SEM2_2014/2015 Page 9 of 22 Printing date: 23/09/2015
10 A Diagram D1 B C Question 11 Diagram D1 represents the class structure of part of a Java application. Which of the following statements about that Java application is true? (a) If an instance of A is declared it will contain 1 instance of B. (b) If an instance of A is declared then when it is no longer accessible all references to the instances of C that are within an instance of B whose instance is within A will become inaccessible. (c) If an instance of A is declared then it will contain 50 instances of C. (d) The relationship between the class B and the class C is aggregation (has-a). Question 12 Diagram D1 represents the class structure of part of a program. In an implementation of class A (assume appropriate import statements have been made) which of the following declarations for state would help in the representation of all of the state of class A. (a) B state = new B(); (b) B state[] = new B[5]; (c) HashMap<A,C> state = new HashMap<>(); (d) TreeMap<A, ArrayList<C>> state = new TreeMap<>(); CI101_SEM2_2014/2015 Page 10 of 22 Printing date: 23/09/2015
11 Question 13 Which of the following statements about the Java language is true? (a) (b) (c) (d) An instance of an ArrayList may be extended by inserting a new element at the end. An instance of an ArrayList has an index that goes from 1 to the number of elements in the ArrayList. There is no way at run time of finding the number of elements in an instance of an ArrayList after new elements have been added. An instance of an ArrayList<Integer> may be used to store an instance of the primitive type double. Question 14 Which of the following statements about the Java language is true? (a) The Java collection class HashMap internally stores its keys in ascending order. (b) String pw = "North Meols".charAt(1); Will put "o" into the variable pw. (c) System.out.println( "hello".tolowercase() ); Will print hello (d) final double pi = 3.14; In subsequent code the value of pi may be changed to a better (more accurate) representation of pi. Question 15 Which of the following statements about the use of the architectural pattern MVC is true? (a) (b) (c) (d) There can only be 1 instance of the View The Model contains code to directly produce a visual representation of the View on an appropriate device. The behaviour of the model is implemented in the View. The view requests information from the model so that it can generate an appropriate representation of the Model. CI101_SEM2_2014/2015 Page 11 of 22 Printing date: 23/09/2015
12 Question 16 Which of the following statements about testing is true? (a) (b) (c) (d) In white box testing the tester does not see the code that they are testing. In black box testing the tester sees the code that they are testing. Using a JUnit test guarantees to discover all errors in the code of a class. In general you will not be able to exhaustively test if all possible inputs to a program will be processed correctly. Question 17 Which of the following statements about the Java language is true? (a) (b) (c) (d) The garbage collector is an attempt by Oracle to improve the detection of errors in a program using AI (Artificial Intelligence) techniques. All classes must have at least one explicit constructor. An import statement can occur anywhere within a Java program as long as the keyword import starts in columns The class construct may itself contain another class. Question 18 Which of the following statements is true? (a) (b) (c) (d) When a Java application with at least one executable statement is successfully compiled there will be at least one file created with extension.class. The debugger in BlueJ will help you find syntax errors in your program. The debugger in BlueJ will help you find semantic errors such as the use of a variable that has not been declared in your program. Any program written in Java today will still be compliable by the original Java compiler released to the world in 1995 hence the phrase "Write once run anywhere". CI101_SEM2_2014/2015 Page 12 of 22 Printing date: 23/09/2015
13 Question 19 Which of the following statements about the Java language is false? (a) (b) (c) (d) It is unwise in a program to hold a large monetary amount in a double if absolute accuracy is required. A boolean is an example of a primitive type. A class is an example of a reference type. In Java only primitive types may be held in an instance of an ArrayList. Question 20 In relationship to the standard conventions used for writing a Java application which of the following is true? (a) (b) (c) (d) As the screen size on many mobile devices is small developers should write their Java code starting at column 1 and then have a maximum of 40 characters on a line to maximise the readability of their code on mobile devices. The convention is that a class name starts with a lower case letter and then may have a mixture of upper and lower case letters. The convention is that a mutable (can be changed at run-time) variable name starts with a lower case letter. The convention is that developers should use very short names for variables and if at all possible a single letter to help speed up the compilation process. CI101_SEM2_2014/2015 Page 13 of 22 Printing date: 23/09/2015
14 Marks Section B Section B carries 50 marks Brief A Java application has been written to process data electronically collected by a meter reader. The application reads the processed collected data looking for anomalies in the readings gathered. The processed data consists of the customer's reference number, the current meter reading and then the previous meter reading. A customer's reference number of 0 terminates the data. The anomalies that can be identified in the data are as follows: Anomaly.Description / what is to be printed 1 No units used The message: "No usage" is printed. 2 The current reading is less than the previous reading The message: "Usage: current [val] is less than previous [val]" Is printed with val replaced by the appropriate meter reading. 3 A very high usage (> units is found) The message "Very high usage [val]" Is printed with val replaced by the usage Unfortunately the application contains in total 5 (Five) syntax, semantic or logical errors. Correct these errors in the program. Remember, it is to correct the errors not rewrite the Java application. PTO CI101_SEM2_2014/2015 Page 14 of 22 Printing date: 23/09/2015
15 Example input data Commentary Example Input Expected output Reading 1 Reading 2 Reading 3 Customer Investigate Usage: current [4] less than previous [8] No usage Very high usage [11000] // Customer ID // Current // Previous // End of data Special instructions Remember any line printed that contains a # will not be considered as part of your answer. This is so that you can write out a meaningful prompt for any data (containing a # character) and this line of text will be ignored in the comparison of your answer. The Java application A printed copy of the Java application for question 2.1(that contains the 5 (Five) errors mentioned above) is on the following page. PTO CI101_SEM2_2014/2015 Page 15 of 22 Printing date: 23/09/2015
16 //Please enter your student number here: // ^^^^^^^^ class Main public static void main( String args[] ) System.out.println("Customer Investigate" ); System.out.print( "#Enter ref. number: " ); int customer = BIO.getInt(); while ( customer > 0 ) System.out.print( "#Current use " ); int current = BIO.getInt(); System.out.print( "#Previuous use " ); int previous = BIO.getInt(); used = current - previous; if ( used > ) report( customer, "Very high usage [%d]", used, 0 ); if ( used <= 0 ) report( customer, "Usage: current [%d] less than previous [%d]", previous, current ); if ( used = 0 ) report( customer, "No usage", 0, 0 ); System.out.print( "#Enter Customer id " ); customer = BIO.getInt(); public static void report( int customer, String what, int val1, int val2 ) System.out.printf( "%8d ", customer ); System.out.printf( what, val1, val2 ); System.out.print(); There are 3 marks for each 'issue' successfully corrected. CI101_SEM2_2014/2015 Page 16 of 22 Printing date: 23/09/2015
17 Marks Brief Construct a Java program that will read in a single integer value representing the side of a square that is to be printed. When the square is printed the outline of the square is represented by * s and the interior is filled with alternate blank columns and columns filled with * s. For example, if 7 were input then the square would be 7 columns wide by 7 rows deep as shown below: ******* * * * * * * * * * * * * * * * * * * * * ******* Counting from 1 for the above square of size 7, the vertical bars (includes the left hand and right hand sides) would be at columns 1, 3, 5 and 7. However, if the size of the square read in is not appropriate then the error message "Not possible" is to be printed instead of printing the square. An inappropriate size for a square is less than 5 or an even number. Hint A positive number is even if - the remainder when divided by 2 is 0. A positive number is odd if - the remainder when divided by 2 is 1. PTO CI101_SEM2_2014/2015 Page 17 of 22 Printing date: 23/09/2015
18 Example input data Commentary Example Input 7 Size of square Expected output ******* * * * * * * * * * * * * * * * * * * * * ******* Example Input Expected output 4 Size of square Not possible Example Input 9 Size of square Expected output ********* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ********* CI101_SEM2_2014/2015 Page 18 of 22 Printing date: 23/09/2015
19 Marks Program solution (17 marks for a working program) Elegance/ appropriateness of solution (Max 3 marks) Brief Before the 15 th February 1971, the UK used a monetary system that was comprised of pounds, shilling and pence. A pound was made up of 20 shillings and 1 shilling was made up of 12 pence. Rather confusingly the symbol for pence was then d. Hence in the old monetary system there were 240d in a pound. This old monetary system was often referred to as sd or occasionally as L.s.d (LSD) which stood for the Latin currency denominations of librae, solidi, and denarii. Implement the class LSD that is used to hold instance of money in 'pounds, shillings and pence'. The class LSD implements the interface LSD_Protocol. The interface LSD_Protocol is defined on the following page which contains "java doc" comments about what each method does. Complete the methods in the class that you create in the following order: set asstring add sub mult divide The checking process used on your code, will first test the method set, then asstring, then add etc. Do make sure that the class LSD that you 'submit' compiles and you complete the methods in the order shown above. PTO CI101_SEM2_2014/2015 Page 19 of 22 Printing date: 23/09/2015
20 interface LSD_Protocol /** * Set the amount to (in old money) * returns false if shillings < 0 or > 20 * pence < 0 or > 12 pounds Number of pounds shillings Number of shillings pence Number of pence true if valid amount false otherwise */ public boolean set(int pounds, int shillings, int pence); /** * Return as a String a representation of the * amount held in Pounds Shilling and Pence * 2 3shillings 6pence => "P2 3s 6d" * 0 0shillings 6pence => "P0 0s 6d" String representing the amount in old money */ public String asstring(); /** * Add to the amount (in old money): pounds Number of pounds; shillings Number of shillings pence Number of pence */ public void add( int pounds, int shillings, int pence ); /** * Subtract from the amount (in old money): pounds Number of pounds; shillings Number of shillings pence Number of pence */ public void sub( int pounds, int shillings, int pence ); /** * Multiply the amount held by: by Number to multiply by */ public void mult( int by ); /** * Divide the amount held by * [The answer is the equivalent of (value in pence)/by] by Number to divide by */ public void divide( int by ); PTO CI101_SEM2_2014/2015 Page 20 of 22 Printing date: 23/09/2015
21 The following program (In class Main) can be used as a quick test for the class LSD. class Main public static void main( String args[] ) LSD m = new LSD(); System.out.printf( "Answer construct = %s\n", m.asstring() ); boolean check = m.set( 0, 0, 13 ); //Invalid amount if (! check ) System.out.printf( "13 pence Invalid amount\n" ); check = m.set( 0, 21, 0 ); //Invalid amount if (! check ) System.out.printf( "21 shillings Invalid amount\n" ); check = m.set( -7, 19, 11 ); //Valid if (! check ) System.out.printf( "But is valid\n" ); m.set( 10, 4, 0 ); //10 Pounds, 4 Shillings, 0 Pence System.out.printf( "Answer set = %s\n", m.asstring() ); m.set( 0, 0, 0 ); for ( int pounds = 0; pounds < 2; pounds++ ) for ( int shillings=0; shillings < 20; shillings++ ) for ( int pence = 0; pence < 12; pence++ ) m.add( pounds, shillings, pence ); System.out.printf( "Answer add = %s\n", m.asstring() ); m.set( 500, 0, 0 ); for ( int pounds = 0; pounds < 2; pounds++ ) for ( int shillings=0; shillings < 20; shillings++ ) for ( int pence = 0; pence < 12; pence ++ ) m.sub( pounds, shillings, pence ); System.out.printf( "Answer sub = %s\n", m.asstring() ); m.set( 3, 7, 10 ); m.mult( 3 ); System.out.printf( "Answer mult = %s\n", m.asstring() ); m.set( 10, 3, 6 ); m.mult(3); m.divide( 3 ); System.out.printf( "Answer divide = %s\n", m.asstring() ); PTO CI101_SEM2_2014/2015 Page 21 of 22 Printing date: 23/09/2015
22 The result from executing this 'test' program for the class LSD should be: Answer construct = P0 0s 0d 13 pence Invalid amount 21 shillings Invalid amount Answer set = P10 4s 0d Answer add = P479 0s 0d Answer sub = P21 0s 0d Answer mult = P10 3s 6d Answer divide = P10 3s 6d Special instructions Hints A BlueJ project for question 2.3 is provided. In this BlueJ project is the class Main, which contains the test program shown above. The interface LSD_Protocol and finally an incomplete implementation (No state or behaviour) of the class LSD that will not compile. Your task is to complete the class LSD so that the class Main when executed as a program will produce the correct output. When you create the class LSD use the body of the interface to create the methods in the class. Replacing the ';' with an appropriate body for each method. If you do not complete a method make sure that the method will compile so that the class Main can be used to test the other methods that you have implemented. CI101_SEM2_2014/2015 Page 22 of 22 Printing date: 23/09/2015
SCHOOL OF COMPUTING, ENGINEERING AND MATHEMATICS SEMESTER 1 EXAMINATIONS 2015/2016 CI101 / CI177. Programming
s SCHOOL OF COMPUTING, ENGINEERING AND MATHEMATICS SEMESTER 1 EXAMINATIONS 2015/2016 CI101 / CI177 Programming Time allowed: THREE hours: Answer: ALL questions Items permitted: Items supplied: There is
More informationSCHOOL OF COMPUTING, ENGINEERING AND MATHEMATICS SEMESTER 2 EXAMINATIONS 2013/2014 CI101/CI101H. Programming
s SCHOOL OF COMPUTING, ENGINEERING AND MATHEMATICS SEMESTER 2 EXAMINATIONS 2013/2014 CI101/CI101H Programming Time allowed: THREE hours Answer: ALL questions Items permitted: Items supplied: There is no
More informationIn the following description the h: drive is used to indicate the directory in which during the actual ci101 exam the files used will reside.
Important In the following description the h: drive is used to indicate the directory in which during the actual ci101 exam the files used will reside. However, if you are trying the exam system out yourself
More informationIntroduction to the coursework for CI228
Introduction to the coursework for CI228 It is very unlikely that you would be able to complete this coursework without attending lectures and tutorials and following the suggested completion deadlines.
More informationC212 Early Evaluation Exam Mon Feb Name: Please provide brief (common sense) justifications with your answers below.
C212 Early Evaluation Exam Mon Feb 10 2014 Name: Please provide brief (common sense) justifications with your answers below. 1. What is the type (and value) of this expression: 5 * (7 + 4 / 2) 2. What
More informationCourse Outline. Introduction to java
Course Outline 1. Introduction to OO programming 2. Language Basics Syntax and Semantics 3. Algorithms, stepwise refinements. 4. Quiz/Assignment ( 5. Repetitions (for loops) 6. Writing simple classes 7.
More informationSelected 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 informationSection 2.2 Your First Program in Java: Printing a Line of Text
Chapter 2 Introduction to Java Applications Section 2.2 Your First Program in Java: Printing a Line of Text 2.2 Q1: End-of-line comments that should be ignored by the compiler are denoted using a. Two
More informationProgramming with Java
Programming with Java Data Types & Input Statement Lecture 04 First stage Software Engineering Dep. Saman M. Omer 2017-2018 Objectives q By the end of this lecture you should be able to : ü Know rules
More informationAPCS Semester #1 Final Exam Practice Problems
Name: Date: Per: AP Computer Science, Mr. Ferraro APCS Semester #1 Final Exam Practice Problems The problems here are to get you thinking about topics we ve visited thus far in preparation for the semester
More informationBuilding Java Programs. Chapter 2: Primitive Data and Definite Loops
Building Java Programs Chapter 2: Primitive Data and Definite Loops Copyright 2008 2006 by Pearson Education 1 Lecture outline data concepts Primitive types: int, double, char (for now) Expressions: operators,
More informationGrouping Objects. Primitive Arrays and Iteration. Produced by: Dr. Siobhán Drohan. Department of Computing and Mathematics
Grouping Objects Primitive Arrays and Iteration Produced by: Dr. Siobhán Drohan Department of Computing and Mathematics http://www.wit.ie/ Topic List Primitive arrays Why do we need them? What are they?
More informationData Structures. Data structures. Data structures. What is a data structure? Simple answer: a collection of data equipped with some operations.
Data Structures 1 Data structures What is a data structure? Simple answer: a collection of data equipped with some operations. Examples Lists Strings... 2 Data structures In this course, we will learn
More informationComputer Components. Software{ User Programs. Operating System. Hardware
Computer Components Software{ User Programs Operating System Hardware What are Programs? Programs provide instructions for computers Similar to giving directions to a person who is trying to get from point
More informationFull file at
Chapter 2 Introduction to Java Applications Section 2.1 Introduction ( none ) Section 2.2 First Program in Java: Printing a Line of Text 2.2 Q1: End-of-line comments that should be ignored by the compiler
More informationPROGRAMMING FUNDAMENTALS
PROGRAMMING FUNDAMENTALS Q1. Name any two Object Oriented Programming languages? Q2. Why is java called a platform independent language? Q3. Elaborate the java Compilation process. Q4. Why do we write
More informationCOMP 202 Java in one week
COMP 202 Java in one week... Continued CONTENTS: Return to material from previous lecture At-home programming exercises Please Do Ask Questions It's perfectly normal not to understand everything Most of
More informationUniversity of Cape Town ~ Department of Computer Science. Computer Science 1015F ~ 2007
Name: Please fill in your Student Number and Name. Student Number : Student Number: University of Cape Town ~ Department of Computer Science Computer Science 1015F ~ 2007 Final Examination Question Max
More informationCS 101 Fall 2006 Midterm 3 Name: ID:
You only need to write your name and e-mail ID on the first page. This exam is CLOSED text book, closed-notes, closed-calculator, closed-neighbor, etc. Questions are worth different amounts, so be sure
More informationMcGill University School of Computer Science COMP-202A Introduction to Computing 1
McGill University School of Computer Science COMP-202A Introduction to Computing 1 Midterm Exam Thursday, October 26, 2006, 18:00-20:00 (6:00 8:00 PM) Instructors: Mathieu Petitpas, Shah Asaduzzaman, Sherif
More information1 Introduction Java, the beginning Java Virtual Machine A First Program BlueJ Raspberry Pi...
Contents 1 Introduction 3 1.1 Java, the beginning.......................... 3 1.2 Java Virtual Machine........................ 4 1.3 A First Program........................... 4 1.4 BlueJ.................................
More informationWhat we will do today Explain and look at examples of. Programs that examine data. Data types. Topic 4. variables. expressions. assignment statements
Topic 4 Variables Once a programmer has understood the use of variables, he has understood the essence of programming -Edsger Dijkstra What we will do today Explain and look at examples of primitive data
More informationBASIC COMPUTATION. public static void main(string [] args) Fundamentals of Computer Science I
BASIC COMPUTATION x public static void main(string [] args) Fundamentals of Computer Science I Outline Using Eclipse Data Types Variables Primitive and Class Data Types Expressions Declaration Assignment
More informationCI228 CI228 Tutorials
CI228 M A Smith University of Brighton September 13, 2016 Page 1 BIO - Basic Input Output Input of an integer number The static method BIO.getInt() will read from the keyboard an integer number typed by
More informationEXAM Computer Science 1 Part 1
Maastricht University Faculty of Humanities and Science Department of Knowledge Engineering EXAM Computer Science 1 Part 1 Block 1.1: Computer Science 1 Code: KEN1120 Examiner: Kurt Driessens Date: Januari
More informationDarrell Bethea May 25, 2011
Darrell Bethea May 25, 2011 Yesterdays slides updated Midterm on tomorrow in SN014 Closed books, no notes, no computer Program 3 due Tuesday 2 3 A whirlwind tour of almost everything we have covered so
More informationCOMP-202: Foundations of Programming. Lecture 2: Variables, and Data Types Sandeep Manjanna, Summer 2015
COMP-202: Foundations of Programming Lecture 2: Variables, and Data Types Sandeep Manjanna, Summer 2015 Announcements Midterm Exams on 4 th of June (12:35 14:35) Room allocation will be announced soon
More informationSection 2.2 Your First Program in Java: Printing a Line of Text
Chapter 2 Introduction to Java Applications Section 2.2 Your First Program in Java: Printing a Line of Text 2.2 Q1: End-of-line comments that should be ignored by the compiler are denoted using a. Two
More informationThis is a copy of the notes used in the module CI01.
CI101 This is a copy of the notes used in the module CI01. It is presented to you in the hope that it will be useful and reduce some of the burden of taking notes during the lectures. However, it will
More informationActivity 1: Introduction
Activity 1: Introduction In this course, you will work in teams of 3 4 students to learn new concepts. This activity will introduce you to the process. We ll also take a first look at how to store data
More informationCoding Standards for Java
Why have coding standards? Coding Standards for Java Version 1.3 It is a known fact that 80% of the lifetime cost of a piece of software goes to maintenance; therefore, it makes sense for all programs
More informationIntroduction to Java Applications
2 Introduction to Java Applications OBJECTIVES In this chapter you will learn: To write simple Java applications. To use input and output statements. Java s primitive types. Basic memory concepts. To use
More informationNATIONAL UNIVERSITY OF SINGAPORE
NATIONAL UNIVERSITY OF SINGAPORE SCHOOL OF COMPUTING TERM TEST #1 Semester 1 AY2006/2007 CS1101X/Y/Z PROGRAMMING METHODOLOGY 16 September 2006 Time Allowed: 60 Minutes INSTRUCTIONS 1. This question paper
More informationBasics of programming
0. Java summary Core char int double boolean short long float primitive types; int a = 2; int b = 2, c = 4; Declaration of a variable a = b; a = b + c; Assignment b + c; // Addition b - c; // Subtraction
More informationDatatypes, Variables, and Operations
Datatypes, Variables, and Operations 1 Primitive Type Classification 2 Numerical Data Types Name Range Storage Size byte 2 7 to 2 7 1 (-128 to 127) 8-bit signed short 2 15 to 2 15 1 (-32768 to 32767) 16-bit
More informationUniversità degli Studi di Bologna Facoltà di Ingegneria. Principles, Models, and Applications for Distributed Systems M
Università degli Studi di Bologna Facoltà di Ingegneria Principles, Models, and Applications for Distributed Systems M tutor Isam M. Al Jawarneh, PhD student isam.aljawarneh3@unibo.it Mobile Middleware
More informationcis20.1 design and implementation of software applications I fall 2007 lecture # I.2 topics: introduction to java, part 1
topics: introduction to java, part 1 cis20.1 design and implementation of software applications I fall 2007 lecture # I.2 cis20.1-fall2007-sklar-leci.2 1 Java. Java is an object-oriented language: it is
More informationMenu Driven Systems. While loops, menus and the switch statement. Mairead Meagher Dr. Siobhán Drohan. Produced by:
Menu Driven Systems While loops, menus and the switch statement Produced by: Mairead Meagher Dr. Siobhán Drohan Department of Computing and Mathematics http://www.wit.ie/ Topics list while loops recap
More informationBuilding Java Programs
Building Java Programs Chapter 2 Lecture 2-1: Expressions and Variables reading: 2.1-2.2 1 2 Data and expressions reading: 2.1 3 The computer s view Internally, computers store everything as 1 s and 0
More information1B1a Arrays. Arrays. Indexing. Naming arrays. Why? Using indexing. 1B1a Lecture Slides. Copyright 2003, Graham Roberts 1
Ba Arrays Arrays A normal variable holds value: An array variable holds a collection of values: 4 Naming arrays An array has a single name, so the elements are numbered or indexed. 0 3 4 5 Numbering starts
More informationCSE 1223: Exam II Autumn 2016
CSE 1223: Exam II Autumn 2016 Name: Instructions: Do not open the exam before you are told to begin. This exam is closed book, closed notes. You may not use any calculators or any other kind of computing
More informationObject-Oriented Programming
Object-Oriented Programming Java Syntax Program Structure Variables and basic data types. Industry standard naming conventions. Java syntax and coding conventions If Then Else Case statements Looping (for,
More informationMidterms Save the Dates!
University of British Columbia CPSC 111, Intro to Computation Alan J. Hu Primitive Data Types Arithmetic Operators Readings Your textbook is Big Java (3rd Ed). This Week s Reading: Ch 2.1-2.5, Ch 4.1-4.2.
More informationDo not start the test until instructed to do so!
CS 1054: Programming in Java Page 1 of 6 Form A READ THIS NOW! Failure to read and follow the instructions below may result in severe penalties Failure to adhere to these directions will not constitute
More informationFull file at
Java Programming: From Problem Analysis to Program Design, 3 rd Edition 2-1 Chapter 2 Basic Elements of Java At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class
More informationJava Simple Data Types
Intro to Java Unit 1 Multiple Choice Test Key Java Simple Data Types This Test Is a KEY DO NOT WRITE ON THIS TEST This test includes program segments, which are not complete programs. Answer such questions
More informationSemester 1 CI101/CI177. Java
Semester 1 CI101/CI177 Java Object oriented programming M A Smith University of Brighton March 20, 2017 Page 1 This is a copy of the notes used in the module CI01. It is presented to you in the hope that
More informationIntroduction to Software Development (ISD) Week 3
Introduction to Software Development (ISD) Week 3 Autumn term 2012 Aims of Week 3 To learn about while, for, and do loops To understand and use nested loops To implement programs that read and process
More information1007 Imperative Programming Part II
Agenda 1007 Imperative Programming Part II We ve seen the basic ideas of sequence, iteration and selection. Now let s look at what else we need to start writing useful programs. Details now start to be
More informationTopic 4 Expressions and variables
Topic 4 Expressions and variables "Once a person has understood the way variables are used in programming, he has understood the quintessence of programming." -Professor Edsger W. Dijkstra Based on slides
More informationObject-Oriented Programming. Topic 2: Fundamental Programming Structures in Java
Electrical and Computer Engineering Object-Oriented Topic 2: Fundamental Structures in Java Maj Joel Young Joel.Young@afit.edu 8-Sep-03 Maj Joel Young Java Identifiers Identifiers Used to name local variables
More informationArray Basics: Outline. Creating and Accessing Arrays. Creating and Accessing Arrays. Arrays (Savitch, Chapter 7)
Array Basics: Outline Arrays (Savitch, Chapter 7) TOPICS Array Basics Arrays in Classes and Methods Programming with Arrays Searching and Sorting Arrays Multi-Dimensional Arrays Static Variables and Constants
More informationCOMP 202 Java in one week
CONTENTS: Basics of Programming Variables and Assignment Data Types: int, float, (string) Example: Implementing a calculator COMP 202 Java in one week The Java Programming Language A programming language
More informationCSI 1100 / 1500 Fall 2004 Introduction to Computer Science I Final Examination
CSI 1100 / 1500 Final Examination Page 1 of 13 CSI 1100 / 1500 Fall 2004 Introduction to Computer Science I Final Examination Duration : 3 hours 09:30 December 9, 2004 Professors: Alan Williams, Daniel
More informationCS111: PROGRAMMING LANGUAGE II
1 CS111: PROGRAMMING LANGUAGE II Computer Science Department Lecture 1: Introduction Lecture Contents 2 Course info Why programming?? Why Java?? Write once, run anywhere!! Java basics Input/output Variables
More informationUniversity of Cape Town ~ Department of Computer Science Computer Science 1015F ~ June Exam
Name: Please fill in your Student Number and Name. Student Number : Student Number: University of Cape Town ~ Department of Computer Science Computer Science 1015F ~ 2009 June Exam Question Max Internal
More informationData types Expressions Variables Assignment. COMP1400 Week 2
Data types Expressions Variables Assignment COMP1400 Week 2 Data types Data come in different types. The type of a piece of data describes: What the data means. What we can do with it. Primitive types
More informationBasics of Java Programming
Basics of Java Programming Lecture 2 COP 3252 Summer 2017 May 16, 2017 Components of a Java Program statements - A statement is some action or sequence of actions, given as a command in code. A statement
More informationCOS 126 General Computer Science Spring Written Exam 1
COS 126 General Computer Science Spring 2017 Written Exam 1 This exam has 9 questions (including question 0) worth a total of 70 points. You have 50 minutes. Write all answers inside the designated spaces.
More informationSt. Edmund Preparatory High School Brooklyn, NY
AP Computer Science Mr. A. Pinnavaia Summer Assignment St. Edmund Preparatory High School Name: I know it has been about 7 months since you last thought about programming. It s ok. I wouldn t want to think
More information2.8. Decision Making: Equality and Relational Operators
Page 1 of 6 [Page 56] 2.8. Decision Making: Equality and Relational Operators A condition is an expression that can be either true or false. This section introduces a simple version of Java's if statement
More informationCS 307 Midterm 2 Spring 2008
Points off 1 2 3 4 Total off Net Score Exam Number: CS 307 Midterm 2 Spring 2008 Name UTEID login name TA's Name: Mario Ruchica Vishvas (Circle One) Instructions: 1. Please turn off your cell phones and
More informationKey Concept: all programs can be broken down to a combination of one of the six instructions Assignment Statements can create variables to represent
Programming 2 Key Concept: all programs can be broken down to a combination of one of the six instructions Assignment Statements can create variables to represent information Input can receive information
More informationProgram Fundamentals
Program Fundamentals /* HelloWorld.java * The classic Hello, world! program */ class HelloWorld { public static void main (String[ ] args) { System.out.println( Hello, world! ); } } /* HelloWorld.java
More informationCSCI 135 Exam #2 Fundamentals of Computer Science I Fall 2013
CSCI 135 Exam #2 Fundamentals of Computer Science I Fall 2013 Name: This exam consists of 6 problems on the following 6 pages. You may use your two-sided hand-written 8 ½ x 11 note sheet during the exam.
More informationMr. Monroe s Guide to Mastering Java Syntax
Mr. Monroe s Guide to Mastering Java Syntax Getting Started with Java 1. Download and install the official JDK (Java Development Kit). 2. Download an IDE (Integrated Development Environment), like BlueJ.
More informationCS 231 Data Structures and Algorithms, Fall 2016
CS 231 Data Structures and Algorithms, Fall 2016 Dr. Bruce A. Maxwell Department of Computer Science Colby College Course Description Focuses on the common structures used to store data and the standard
More informationJava Basics Programming Fundamentals
Java Basics Programming Fundamentals The 2009 Multiple Choice section of the AP Computer Science A exam was broken down as follows: Programming fundamentals - 30/40 Data Structures - 8/40 Logic - 4/40
More informationSimple Java Reference
Simple Java Reference This document provides a reference to all the Java syntax used in the Computational Methods course. 1 Compiling and running... 2 2 The main() method... 3 3 Primitive variable types...
More informationSPRING 13 CS 0007 FINAL EXAM V2 (Roberts) Your Name: A pt each. B pt each. C pt each. D or 2 pts each
Your Name: Your Pitt (mail NOT peoplesoft) ID: Part Question/s Points available Rubric Your Score A 1-6 6 1 pt each B 7-12 6 1 pt each C 13-16 4 1 pt each D 17-19 5 1 or 2 pts each E 20-23 5 1 or 2 pts
More information1.00/1.001 Tutorial 1
1.00/1.001 Tutorial 1 Introduction to 1.00 September 12 & 13, 2005 Outline Introductions Administrative Stuff Java Basics Eclipse practice PS1 practice Introductions Me Course TA You Name, nickname, major,
More informationIntroduction to C# Applications
1 2 3 Introduction to C# Applications OBJECTIVES To write simple C# applications To write statements that input and output data to the screen. To declare and use data of various types. To write decision-making
More informationSubject: PROBLEM SOLVING THROUGH C Time: 3 Hours Max. Marks: 100
Code: DC-05 Subject: PROBLEM SOLVING THROUGH C Time: 3 Hours Max. Marks: 100 NOTE: There are 11 Questions in all. Question 1 is compulsory and carries 16 marks. Answer to Q. 1. must be written in the space
More informationFinal Exam. COMP Summer I June 26, points
Final Exam COMP 14-090 Summer I 2000 June 26, 2000 200 points 1. Closed book and closed notes. No outside material allowed. 2. Write all answers on the test itself. Do not write any answers in a blue book
More informationCS Introduction to Programming Midterm Exam #1 - Prof. Reed Spring 2010
CS 102 - Introduction to Programming Midterm Exam #1 - Prof. Reed Spring 2010 What is your name?: There are two sections: I. True/False..................... 60 points; ( 30 questions, 2 points each) II.
More informationTerm 1 Unit 1 Week 1 Worksheet: Output Solution
4 Term 1 Unit 1 Week 1 Worksheet: Output Solution Consider the following what is output? 1. System.out.println("hot"); System.out.println("dog"); Output hot dog 2. System.out.print("hot\n\t\t"); System.out.println("dog");
More informationComputing Science 114 Solutions to Midterm Examination Tuesday October 19, In Questions 1 20, Circle EXACTLY ONE choice as the best answer
Computing Science 114 Solutions to Midterm Examination Tuesday October 19, 2004 INSTRUCTOR: I E LEONARD TIME: 50 MINUTES In Questions 1 20, Circle EXACTLY ONE choice as the best answer 1 [2 pts] What company
More informationComputer Programming, I. Laboratory Manual. Experiment #2. Elementary Programming
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 Experiment #2
More information1. [3 pts] What is your section number, the period your discussion meets, and the name of your discussion leader?
CIS 3022 Prog for CIS Majors I October 4, 2007 Exam I Print Your Name Your Section # Total Score Your work is to be done individually. The exam is worth 104 points (four points of extra credit are available
More informationLec 3. Compilers, Debugging, Hello World, and Variables
Lec 3 Compilers, Debugging, Hello World, and Variables Announcements First book reading due tonight at midnight Complete 80% of all activities to get 100% HW1 due Saturday at midnight Lab hours posted
More informationB.V. Patel Institute of BMC & IT, UTU 2014
BCA 3 rd Semester 030010301 - Java Programming Unit-1(Java Platform and Programming Elements) Q-1 Answer the following question in short. [1 Mark each] 1. Who is known as creator of JAVA? 2. Why do we
More informationOutline. Object Oriented Programming. Course goals. Staff. Course resources. Assignments. Course organization Introduction Java overview Autumn 2003
Outline Object Oriented Programming Autumn 2003 2 Course goals Software design vs hacking Abstractions vs language (syntax) Java used to illustrate concepts NOT a course about Java Prerequisites knowledge
More informationIntroduction to Classes and Objects Pearson Education, Inc. All rights reserved.
1 3 Introduction to Classes and Objects 2 You will see something new. Two things. And I call them Thing One and Thing Two. Dr. Theodor Seuss Geisel Nothing can have value without being an object of utility.
More informationCS18000: Problem Solving And Object-Oriented Programming
CS18000: Problem Solving And Object-Oriented Programming Class (and Program) Structure 31 January 2011 Prof. Chris Clifton Classes and Objects Set of real or virtual objects Represent Template in Java
More informationSAMPLE QUESTIONS FOR DIPLOMA IN INFORMATION TECHNOLOGY; YEAR 1
FACULTY OF SCIENCE AND TECHNOLOGY SAMPLE QUESTIONS FOR DIPLOMA IN INFORMATION TECHNOLOGY; YEAR 1 ACADEMIC SESSION 2014; SEMESTER 3 PRG102D: BASIC PROGRAMMING CONCEPTS Section A Compulsory section Question
More informationUniversity of Cape Town ~ Department of Computer Science. Computer Science 1015F ~ 2007
Name: Please fill in your Student Number and Name. Student Number : Student Number: University of Cape Town ~ Department of Computer Science Computer Science 1015F ~ 2007 Supplementary Examination Question
More informationCS 139 Practice Midterm Questions #2
CS 139 Practice Midterm Questions #2 Spring 2016 Name: 1. Write Java statements to accomplish each of the following. (a) Declares numbers to be an array of int s. (b) Initializes numbers to contain a reference
More informationComputer Components. Software{ User Programs. Operating System. Hardware
Computer Components Software{ User Programs Operating System Hardware What are Programs? Programs provide instructions for computers Similar to giving directions to a person who is trying to get from point
More informationData and Variables. Data Types Expressions. String Concatenation Variables Declaration Assignment Shorthand operators. Operators Precedence
Data and Variables Data Types Expressions Operators Precedence String Concatenation Variables Declaration Assignment Shorthand operators Review class All code in a java file is written in a class public
More informationCSCI 135 Exam #2 Fundamentals of Computer Science I Fall 2013
CSCI 135 Exam #2 Fundamentals of Computer Science I Fall 2013 Name: This exam consists of 6 problems on the following 6 pages. You may use your two-sided hand-written 8 ½ x 11 note sheet during the exam.
More information12/22/11. Java How to Program, 9/e. Help you get started with Eclipse and NetBeans integrated development environments.
Java How to Program, 9/e Education, Inc. All Rights Reserved. } Java application programming } Use tools from the JDK to compile and run programs. } Videos at www.deitel.com/books/jhtp9/ Help you get started
More informationCollections, Maps and Generics
Collections API Collections, Maps and Generics You've already used ArrayList for exercises from the previous semester, but ArrayList is just one part of much larger Collections API that Java provides.
More informationKey Java Simple Data Types
AP CS P w Java Unit 1 Multiple Choice Practice Key Java Simple Data Types This test includes program segments, which are not complete programs. Answer such questions with the assumption that the program
More informationData dependent execution order data dependent control flow
Chapter 5 Data dependent execution order data dependent control flow The method of an object processes data using statements, e.g., for assignment of values to variables and for in- and output. The execution
More informationCONTENTS: Array Usage Multi-Dimensional Arrays Reference Types. COMP-202 Unit 6: Arrays
CONTENTS: Array Usage Multi-Dimensional Arrays Reference Types COMP-202 Unit 6: Arrays Introduction (1) Suppose you want to write a program that asks the user to enter the numeric final grades of 350 COMP-202
More informationUse the scantron sheet to enter the answer to questions (pages 1-6)
Use the scantron sheet to enter the answer to questions 1-100 (pages 1-6) Part I. Mark A for True, B for false. (1 point each) 1. Abstraction allow us to specify an object regardless of how the object
More informationUnit 5: More on Classes/Objects Notes
Unit 5: More on Classes/Objects Notes AP CS A The Difference between Primitive and Object/Reference Data Types First, remember the definition of a variable. A variable is a. So, an obvious question is:
More informationLast Name: Circle One: OCW Non-OCW
First Name: AITI 2004: Exam 1 June 30, 2004 Last Name: Circle One: OCW Non-OCW Read Instructions Carefully! This is a 3 hour closed book exam. No calculators are allowed. Please write clearly if we cannot
More informationLesson 02 Data Types and Statements. MIT 12043, Fundamentals of Programming By: S. Sabraz Nawaz Senior Lecturer in MIT Department of MIT FMC, SEUSL
Lesson 02 Data Types and Statements MIT 12043, Fundamentals of Programming By: S. Sabraz Nawaz Senior Lecturer in MIT Department of MIT FMC, SEUSL Topics Covered Statements Variables Constants Data Types
More informationIntroduction to Java https://tinyurl.com/y7bvpa9z
Introduction to Java https://tinyurl.com/y7bvpa9z Eric Newhall - Laurence Meyers Team 2849 Alumni Java Object-Oriented Compiled Garbage-Collected WORA - Write Once, Run Anywhere IDE Integrated Development
More information