JAVA Revision Lecture Electronic Voting System Marina De Vos.

Slides:



Advertisements
Similar presentations
AP Computer Science Anthony Keen. Computer 101 What happens when you turn a computer on? –BIOS tries to start a system loader –A system loader tries to.
Advertisements

Understanding class definitions Looking inside classes 5.0.
Looking inside classes Fields, Constructors & Methods Week 3.
Based on Java Software Development, 5th Ed. By Lewis &Loftus
Core Java Lecture 4-5. What We Will Cover Today What Are Methods Scope and Life Time of Variables Command Line Arguments Use of static keyword in Java.
July 13 th.  If/ Else if / Else  Variable Scope  Nested if/else's  Switch statements  Conditional Operator.
Enhancing the student learning and the student learning experience through an Electronic Voting System. Marina De Vos, Emma Cliffe, James Davenport, Alan.
Looking inside classes Choices Week 4. Class bodies contain fields, constructors and methods. Fields store values that determine an object’s state. Constructors.
Lecture 3: Topics If-then-else Operator precedence While loops Static methods Recursion.
Objects and Classes First Programming Concepts. 14/10/2004Lecture 1a: Introduction 2 Fundamental Concepts object class method parameter data type.
Understanding class definitions – Part II –. Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling Main.
1 Reflecting on the ticket machines Their behavior is inadequate in several ways: –No checks on the amounts entered. –No refunds. –No checks for a sensible.
Understanding class definitions Looking inside classes.
CSC 212 – Data Structures Lecture 12: Java Review.
By Nicholas Policelli An Introduction to Java. Basic Program Structure public class ClassName { public static void main(String[] args) { program statements.
ACO 101: Introduction to Computer Science Anatomy Part 2: Methods.
© A+ Computer Science - public Triangle() { setSides(0,0,0); } Constructors are similar to methods. Constructors set the properties.
Slide 1 Unit Testing. Slide 2 Unit Testing Options l Use N-Unit In a microsoft environment.NET… you can use their supplied N-Unit testing to test your.
Announcements  If you need more review of Java…  I have lots of good resources – talk to me  Use “Additional Help” link on webpage  Weekly assignments.
Agenda Object Oriented Programming Reading: Chapter 14.
ECE122 Feb. 22, Any question on Vehicle sample code?
OOP in Java : © W. Milner 2005 : Slide 1 Java and OOP Part 2 – Classes and objects.
Understanding class definitions
BEGINNING PROGRAMMING.  Literally – giving instructions to a computer so that it does what you want  Practically – using a programming language (such.
02/14/2005 Introduction to Programming with Java, for Beginners Midterm 1 Review.
Chapter 5 Classes and Methods II Lecture Slides to Accompany An Introduction to Computer Science Using Java (2nd Edition) by S.N. Kamin, D. Mickunas, E.
OOP in C++ CS 124. Program Structure C++ Program: collection of files Source (.cpp) files be compiled separately to be linked into an executable Files.
AP Computer Science A – Healdsburg High School 1 Unit 9 - Why Use Classes - Anatomy of a Class.
Copyright by Scott GrissomCh 2 Class Definition Slide 1 Class Structure public class BankAccount{ fields constructor(s) methods } Sample Code Ticket Machine.
Looking inside classes Conditional Statements Week 4.
Topic 8Classes, Objects and Methods 1 Topic 8 l Class and Method Definitions l Information Hiding and Encapsulation l Objects and Reference Classes, Objects,
A: A: double “4” A: “34” 4.
Chapter 5 : Methods Part 2. Returning a Value from a Method  Data can be passed into a method by way of the parameter variables. Data may also be returned.
Object Oriented Programming and Data Abstraction Rowan University Earl Huff.
 Static  Example for Static Field  Example for Static Method  Math class methods  Casting  Scope of Declaration  Method Overloading  Constructor.
Classes - Intermediate
AP Java Ch. 4 Review Question 1  Java methods can return only primitive types (int, double, boolean, etc).
Java: Variables and Methods By Joshua Li Created for the allAboutJavaClasses wikispace.
Lecture 3: More on Classes Textbook: Chapter 2 Recap: –Classes vs. Objects –Q: What comes first a class or an object? –Q: Do we need a class to create.
Understanding class definitions Exploring source code 6.0.
GC211 Data structure Lecture 3 Sara Alhajjam.
Class definitions CITS1001 week 2.
Objects as a programming concept
Examples of Classes & Objects
Agenda Warmup Finish 2.4 Assignments
suggested reading: Java Ch. 6
Understanding class definitions
public class BankAccount{
CLASS DEFINITION (> 1 CONSTRUCTOR)
Review Operation Bingo
Understanding class definitions
CSI-121 Structured Programming Language Lecture 14 Functions (Part 2)
An Introduction to Java – Part II
The this Reference The this reference allows an object to refer to itself That is, the this reference, used inside a method, refers to the object through.
COS 260 DAY 3 Tony Gauvin.
More on Classes and Objects
Unit 6 - Variables - Fundamental Data Types
© A+ Computer Science - OOP © A+ Computer Science -
Class Everything if Java is in a class. The class has a constructor that creates the object. public class ClassName private Field data (instance variables)
Simple Classes in Java CSCI 392 Classes – Part 1.
Understanding class definitions
Which best describes the relationship between classes and objects?
COS 260 DAY 4 Tony Gauvin.
JAVA CLASSES.
CS 1054: Lecture 2, Chapter 1 Objects and Classes.
Topics to cover Instance variables vs. local variables.
SPL – PS3 C++ Classes.
Coming up Variables Quick look at scope Primitives Objects
Day 11 The Last Week!.
Chapter 4 Test Review First day
Presentation transcript:

JAVA Revision Lecture Electronic Voting System Marina De Vos

0a. What are the languages used in this unit? 1.C and Java 2.Python and Java 3.Perl and VisualBasic

0b. Ada Lovelace was the first … 1.female programmer 2.the wife of the first programmer 3.programmer

1. Which one of the sentences is true considering the following lines of code: String country = "England"; Town bath = new Town(country); 1.the class Town contains a constructor with a String as a parameter 2.bath is an instance of the class England 3.bath is an object of type String

2. What is the value returned while calling the method refundBalance(10)? public int refundBalance(int nb){ balance=100; return balance; balance=0; } Same value as before

3. Which one of the following sentences is correct? 1.Fields represent local variables of a method 2.The scope of a local variable is linked to its defining method 3.Fields are defined inside constructors 4.Local variables are defined in the header of a method 5.A private field can be accessed from outside their defining class

4. Which values have the variables a and b after the execution of the following lines of code: int a=3; int b=5; int c=a++; int d=--b; if ((a+1)==d){ c++; b--; } if (c!=b){ a++; } else { b++; } 1.a=3; b=4; 2.a=4; b=4; 3.a=3; b=5; 4.a=5; b=4; 5.a=4; b=5;

5. What is the result of n? boolean pass=false; int n=0; for (int i=0; i<10; i++) { n+=i; if (pass) { i+=2; } pass = !pass; }

6. Why do you need to add 'throws' to a method signature... 1.To Specify the exceptions thrown by a method 2.To specify the exceptions caught by a method 3.To Specify that a method overrides an exception 4.Both 1 and 2 are correct Choice One

7. A 'try' must be followed by one or more 'catch' blocks. 1.True 2.False

8. What happens to the object being created when an exception is thrown from a constructor? 1.null is returned and the partial object is garbage collected 2.a partial object is created 3.null is returned 4.the object is fully created

9. Code that is well designed is: 1.tighly coupled and not cohesive 2.loosly coupled and not cohesive 3.tighly coupled and highly cohesive 4.loosly coupled and highly cohesive

10. Java is a … 1.weakly and statically typed language 2.weakly and dynamically typed language 3.strongly and statically typed language 4.strongly and dynamically typed language

11. The lifetime and scope of a variable a is defined by the enclosing {} braces. 1.True 2.False

12. Object diagrams can present both a static and dynamic view of a program. 1.True 2.False

13. To create a new primitive type in Java, you can... 1.copy an existing primitive type definition and edit 2....you can't! 3.use the new primitive keyword 4.not necessary - all new types are primitive types

14. A & B is the same as B & A for any boolean expression in Java. 1.True 2.False

15. In Java, it is not possible to have more than one method with the same name. 1.True 2.False

16. Consider the following code snippet: What will the output be? HashMap map = new HashMap (); map.put("key1","arr"); map.put("key1","matey"); System.out.println(map.get("key1")); 1.arr 2.Nothing, it will generate an error. 3.arr matey 4.matey

17. Which of the following statements is incorrect? 1.the static type of a variable is either the same as the dynamic type or a superclass 2.polymorphic method calls use the dynamic type 3.The compiler checks the static and dynamic type of a variable 4.an object reference can always be type cast back to its dynamic type

18 Newly declared methods can hide, implement, or override methods declared in a superclass or superinterface. 1.True 2.False

19 It is possible to have a variable with a static type corresponding to an abstract class 1.True 2.False

20 To simulate multiple inheritance you use: 1.nested classes 2.abstract classes 3.interfaces 4.inherited classes

EVS is good fun, something different and its very good to be interactive Since we do not get much class participation, except if we want to ask questions 1.Strongly Agree 2.Agree 3.Neutral 4.Disagree 5.Strongly Disagree

Java EVS vs Python Quiz 1.evs 2.Quiz 3.I liked both 4.I liked neither

EVS: Although good for general feed-back how we are doing, its not so good for passing course material on. 1.Strongly Agree 2.Agree 3.Neutral 4.Disagree 5.Strongly Disagree