Exam Part 3. Q.1) What is the output of the following code?

Size: px
Start display at page:

Download "Exam Part 3. Q.1) What is the output of the following code?"

Transcription

1 Q.1) What is the output of the following code? Exam Part 3 import java.util.*; // line 1 class EJavaGuruArrayList { // line 2 // line 3 ArrayList<String> ejg = new ArrayList<>(); // line 4 ejg.add("one"); // line 5 ejg.add("two"); // line 6 System.out.println(ejg.contains(new String("One"))); // line 7 System.out.println(ejg.indexOf("Two")); // line 8 ejg.clear(); // line 9 System.out.println(ejg); // line 10 System.out.println(ejg.get(1)); // line 11 // line 12 // line 13 A) Line 7 prints true B) Line 7 prints false C) Line 8 prints -1 D) Line 8 prints 1 E) Line 9 removes all elements of the list ejg F) Line 9 sets the list ejg to null G) Line 10 prints null H) Line 10 prints [] I) Line 10 prints a value similar to ArrayList@16356 K) Line 11 throws an exception L) Line 11 prints null Q.2) What is the output of the following code? class EJavaGuruString2 { String ejg = "game".replace('a', 'Z').trim().concat("Aa"); ejg.substring(0, 2); System.out.println(ejg); A) gzmeaz D) gz B) gzmeaa E) game C) gzm Q.3) What is the output of the following code? class EJavaGuruStringBuilder { StringBuilder ejg = new StringBuilder( "SUN" ); ejg.append(ejg.delete(3, 6)); System.out.println(ejg); A) 12S512S5 B) 12S12S C) S D) Runtime exception Java SE 7 Programming 1

2 Q.4) What is the output of the following code? class EJavaGuruString2 { String ejg = "game"; ejg.replace('a', 'Z').trim().concat("Aa"); ejg.substring(0, 2); System.out.println(ejg); A) gzmeaz B) gzmeaa C) gzm D) gz E) game Q.5) What is the output of the following code? class EJavaGuruStringBuilder2 { StringBuilder sb1 = new StringBuilder("123456"); sb1.subsequence(2, 4); sb1.deletecharat(3); sb1.reverse(); System.out.println(sb1); A) 521 B) Runtime exception C) D) Q.6) What is the output of the following code? (Select 1 option.) public class Handset { public static void main(string... args) { double price; String model; System.out.println(model + price); A) null0 B) null0.0 C) 0 D) 0.0 E) Compilation error Java SE 7 Programming 2

3 Q.7) What is the output of the following code? (Select 1 option.) class Person { int age; float height; boolean result; String name; public class EJava { public static void main(string arguments[]) { Person person = new Person(); System.out.println(person.name + person.height + person.result + person.age); A) null0.0false0 B) null0false0 C) null0.0ffalse0 D) 0.0false0 E) 0false0 F) 0.0ffalse0 G) null0.0true0 H) 0true0 I) 0.0ftrue0 Q.8) Given the following definitions of the interfaces Movable and Jumpable, the task is to declare a class Person that inherits both of these interfaces. Which of the following code snippets will accomplish this task? (Select 2 options.) interface Movable { interface Jumpable { A) interface Movable { interface Jumpable { class Person implements Movable, Jumpable { B) interface Movable { interface Jumpable { class Person extends Movable, Jumpable { C) interface Movable { interface Jumpable { class Person implements Movable extends Jumpable { D) interface Movable { interface Jumpable implements Movable { class Person implements Jumpable { E) interface Movable { interface Jumpable extends Movable { class Person implements Jumpable { Java SE 7 Programming 3

4 Q.9) Given the following code, which option, if used to replace /* INSERT CODE HERE */, will enable a reference variable of type Roamable to refer to an object of the Phone class? (Select 1 option.) interface Roamable{ class Phone { class Tablet extends Phone implements Roamable { //INSERT CODE HERE A) Roamable var = new Phone(); B) Roamable var = (Roamable)Phone(); C) Roamable var = (Roamable)new Phone(); D) Because interface Roamable and class Phone are unrelated, a reference variable of type Roamable can t refer to an object of class Phone. Q.10) Given: 1. enum MyEnum {HI, ALOHA, HOWDY; 2. public class PassEnum { 3. public static void main(string[] args) { 4. PassEnum p = new PassEnum(); 5. MyEnum[] v = MyEnum.values(); 6. v = MyEnum.getValues(); 7. for(myenum me: MyEnum.values()) p.getenum(me); 8. for(int x = 0; x < MyEnum.values().length; x++) p.getenum(v[x]); 9. for(int x = 0; x < MyEnum.length; x++) p.getenum(v[x]); 10. for(myenum me: v) p.getenum(me); public void getenum(myenum e) { 13. System.out.print(e + " "); 14. Which line(s) of code will cause a compiler error? (Choose all that apply.) A. line 1 B. line 5 C. line 6 D. line 7 E. line 8 F. line 9 G. line 10 H. line 12 Q.11) Which statements are true about comparing two instances of the same class, given that the equals() and hashcode() methods have been properly overridden? (Choose all that apply.) A) If the equals() method returns true, the hashcode() comparison == might return false B) If the equals() method returns false, the hashcode() comparison == might return true C) If the hashcode() comparison == returns true, the equals() method must return true D) If the hashcode() comparison == returns true, the equals() method might return true E) If the hashcode() comparison!= returns true, the equals() method might return true Java SE 7 Programming 4

5 Q.12) Given: public static void main(string[] args) { // INSERT DECLARATION HERE for (int i = 0; i <= 10; i++) { List<Integer> row = new ArrayList<Integer>(); for (int j = 0; j <= 10; j++) row.add(i * j); table.add(row); for (List<Integer> row : table) System.out.println(row); Which statements could be inserted at // INSERT DECLARATION HERE to allow this code to compile and run? (Choose all that apply.) A) List<List<Integer>> table = new List<List<Integer>>(); B) List<List<Integer>> table = new ArrayList<List<Integer>>(); C) List<List<Integer>> table = new ArrayList<ArrayList<Integer>>(); D) List<List, Integer> table = new List<List, Integer>(); E) List<List, Integer> table = new ArrayList<List, Integer>(); F) List<List, Integer> table = new ArrayList<ArrayList, Integer>(); G) None of the above Q.13) Given: import java.util.*; class MapEQ { public static void main(string[] args) { Map<ToDos, String> m = new HashMap<ToDos, String>(); ToDos t1 = new ToDos("Monday"); ToDos t2 = new ToDos("Monday"); ToDos t3 = new ToDos("Tuesday"); m.put(t1, "dolaundry"); m.put(t2, "paybills"); m.put(t3, "cleanattic"); System.out.println(m.size()); class ToDos{ String day; ToDos(String d) { day = d; public boolean equals(object o) { return ((ToDos)o).day == this.day; // public int hashcode() { return 9; Which is correct? (Choose all that apply.) A) As the code stands it will not compile B) As the code stands the output will be 2 C) As the code stands the output will be 3 D) If the hashcode() method is uncommented the output will be 2 E) If the hashcode() method is uncommented the output will be 3 F) If the hashcode() method is uncommented the code will not compile Java SE 7 Programming 5

6 Q.14) Given: 12. public class AccountManager { 13. private Map accounttotals = new HashMap(); 14. private int retirementfund; public int getbalance(string accountname) { 17. Integer total = (Integer) accounttotals.get(accountname); 18. if (total == null) 19. total = Integer.valueOf(0); 20. return total.intvalue(); public void setbalance(string accountname, int amount) { 24. accounttotals.put(accountname, Integer.valueOf(amount)); This class is to be updated to make use of appropriate generic types, with no changes in behavior (for better or worse). Which of these steps could be performed? (Choose three.) A) Replace line 13 with private Map<String, int> accounttotals = new HashMap<String, int>(); B) Replace line 13 with private Map<String, Integer> accounttotals = new HashMap<String, Integer>(); C) Replace line 13 with private Map<String<Integer>> accounttotals = new HashMap<String<Integer>>(); D) Replace lines with int total = accounttotals.get(accountname); if (total == null) total = 0; return total; E) Replace lines with Integer total = accounttotals.get(accountname); if (total == null) total = 0; return total; F) Replace lines with return accounttotals.get(accountname); G) Replace line 24 with accounttotals.put(accountname, amount); H) Replace line 24 with accounttotals.put(accountname, amount.intvalue()); Java SE 7 Programming 6

Midterm Exam CS 251, Intermediate Programming October 8, 2014

Midterm Exam CS 251, Intermediate Programming October 8, 2014 Midterm Exam CS 251, Intermediate Programming October 8, 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

CSCI 136 Written Exam #0 Fundamentals of Computer Science II Spring 2015

CSCI 136 Written Exam #0 Fundamentals of Computer Science II Spring 2015 CSCI 136 Written Exam #0 Fundamentals of Computer Science II Spring 2015 Name: This exam consists of 6 problems on the following 7 pages. You may use your single-sided handwritten 8 ½ x 11 note sheet during

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

AP CS Unit 7: Interfaces Exercises 1. Select the TRUE statement(s).

AP CS Unit 7: Interfaces Exercises 1. Select the TRUE statement(s). AP CS Unit 7: Interfaces Exercises 1. Select the TRUE statement(s). a) This code will not compile because a method cannot specify an interface as a parameter. public class Testing { public static void

More information

AP CS Unit 7: Interfaces Exercises Assume all code compiles unless otherwise suggested.

AP CS Unit 7: Interfaces Exercises Assume all code compiles unless otherwise suggested. AP CS Unit 7: Interfaces Exercises Assume all code compiles unless otherwise suggested. 1. The Nose class... b) will not compile because the m1 method parameter should be named n, not x. 2. The Ears class...

More information

public static boolean isoutside(int min, int max, int value)

public static boolean isoutside(int min, int max, int value) See the 2 APIs attached at the end of this worksheet. 1. Methods: Javadoc Complete the Javadoc comments for the following two methods from the API: (a) / @param @param @param @return @pre. / public static

More information

CMSC 202H. Containers and Iterators

CMSC 202H. Containers and Iterators CMSC 202H Containers and Iterators Container Definition A container is a data structure whose purpose is to hold objects. Most languages support several ways to hold objects Arrays are compiler-supported

More information

Announcements. Java Review. More Announcements. Today. Assembly Language. Machine Language

Announcements. Java Review. More Announcements. Today. Assembly Language. Machine Language Announcements Java Review Java Bootcamp Another session tonight 7-9 in B7 Upson tutorial & solutions also available online Assignment 1 has been posted and is due Monday, July 2, 11:59pm Lecture 2 CS211

More information

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

1.00 Introduction to Computers and Engineering Problem Solving. Quiz 1 March 7, 2003 1.00 Introduction to Computers and Engineering Problem Solving Quiz 1 March 7, 2003 Name: Email Address: TA: Section: You have 90 minutes to complete this exam. For coding questions, you do not need to

More information

Getting started with Java

Getting started with Java Getting started with Java by Vlad Costel Ungureanu for Learn Stuff Programming Languages A programming language is a formal constructed language designed to communicate instructions to a machine, particularly

More information

Name Return type Argument list. Then the new method is said to override the old one. So, what is the objective of subclass?

Name Return type Argument list. Then the new method is said to override the old one. So, what is the objective of subclass? 1. Overriding Methods A subclass can modify behavior inherited from a parent class. A subclass can create a method with different functionality than the parent s method but with the same: Name Return type

More information

public void start(stage st) { GridPane p1 = new GridPane(); String s = "emma"; StringBuilder sb = new StringBuilder(s);

public void start(stage st) { GridPane p1 = new GridPane(); String s = emma; StringBuilder sb = new StringBuilder(s); Sample tasks of the exam paper Task 1 Assume that all required classes are imported, the program has the main method which works correctly. Draw the output of the program. Add dimensions in numbers and

More information

Inheritance (Part 2) Notes Chapter 6

Inheritance (Part 2) Notes Chapter 6 Inheritance (Part 2) Notes Chapter 6 1 Object Dog extends Object Dog PureBreed extends Dog PureBreed Mix BloodHound Komondor... Komondor extends PureBreed 2 Implementing Inheritance suppose you want to

More information

Array. Prepared By - Rifat Shahriyar

Array. Prepared By - Rifat Shahriyar Java More Details Array 2 Arrays A group of variables containing values that all have the same type Arrays are fixed length entities In Java, arrays are objects, so they are considered reference types

More information

Examination Questions Midterm 1

Examination Questions Midterm 1 CS1102s Data Structures and Algorithms 10/2/2010 Examination Questions Midterm 1 This examination question booklet has 9 pages, including this cover page, and contains 15 questions. You have 40 minutes

More information

CIT-590 Final Exam. Name: Penn Key (Not ID number): If you write a number above, you will lose 1 point

CIT-590 Final Exam. Name: Penn Key (Not ID number): If you write a number above, you will lose 1 point 1 CIT-590 Final Exam Name: Penn Key (Not ID number): If you write a number above, you will lose 1 point Instructions: You will have two hours to complete this exam. If you finish in the last 15 minutes,

More information

Classes and Objects 3/28/2017. How can multiple methods within a Java class read and write the same variable?

Classes and Objects 3/28/2017. How can multiple methods within a Java class read and write the same variable? Peer Instruction 8 Classes and Objects How can multiple methods within a Java class read and write the same variable? A. Allow one method to reference a local variable of the other B. Declare a variable

More information

CMSC131. Inheritance. Object. When we talked about Object, I mentioned that all Java classes are "built" on top of that.

CMSC131. Inheritance. Object. When we talked about Object, I mentioned that all Java classes are built on top of that. CMSC131 Inheritance Object When we talked about Object, I mentioned that all Java classes are "built" on top of that. This came up when talking about the Java standard equals operator: boolean equals(object

More information

JAVA WRAPPER CLASSES

JAVA WRAPPER CLASSES JAVA WRAPPER CLASSES Description Each of Java's eight primitive data types has a class dedicated to it. These are known as wrapper classes, because they "wrap" the primitive data type into an object of

More information

Collections and Generics

Collections and Generics Collections and Generics For more details on SUN Certifications, visit http://sunjavasnips.blogspot.com/ Q: 01 Given: 34. HashMap props = new HashMap(); 35. props.put("key45", "some value"); 36. props.put("key12",

More information

Java Fundamentals (II)

Java Fundamentals (II) Chair of Software Engineering Languages in Depth Series: Java Programming Prof. Dr. Bertrand Meyer Java Fundamentals (II) Marco Piccioni static imports Introduced in 5.0 Imported static members of a class

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

INHERITANCE. Spring 2019

INHERITANCE. Spring 2019 INHERITANCE Spring 2019 INHERITANCE BASICS Inheritance is a technique that allows one class to be derived from another A derived class inherits all of the data and methods from the original class Suppose

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

SUN Upgrade for the Sun Certified Java Programmer. SE 6.0. Download Full Version :

SUN Upgrade for the Sun Certified Java Programmer. SE 6.0. Download Full Version : SUN 310-066 Upgrade for the Sun Certified Java Programmer. SE 6.0 Download Full Version : https://killexams.com/pass4sure/exam-detail/310-066 Which statement is true about the set variable on line 12?

More information

For more details on SUN Certifications, visit

For more details on SUN Certifications, visit Java.lang Package For more details on SUN Certifications, visit http://sunjavasnips.blogspot.com/ Q:01 Given: public class Person { private String name, comment; private int age; public Person(String n,

More information

FDK API Manual for Java. FDK API Manual for Java. June FN Pricing

FDK API Manual for Java. FDK API Manual for Java. June FN Pricing FDK API Manual for Java June 2015 FN Pricing Contents Overview... 1 System Environments... 1 Installation files... 1 Runtime Environments... 1 Sample codes... 1 CCallFdk... 8 static void Initialize(String

More information

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

Birkbeck (University of London) Software and Programming 1 In-class Test Mar 2018 Birkbeck (University of London) Software and Programming 1 In-class Test 2.1 22 Mar 2018 Student Name Student Number Answer ALL Questions 1. What output is produced when the following Java program fragment

More information

PROGRAMMING FUNDAMENTALS

PROGRAMMING 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 information

CMSC 202. Containers

CMSC 202. Containers CMSC 202 Containers Container Definition A container is a data structure whose purpose is to hold objects. Most languages support several ways to hold objects. Arrays are compiler-supported containers.

More information

F I N A L E X A M I N A T I O N

F I N A L E X A M I N A T I O N Faculty Of Computer Studies M257 Putting Java to Work F I N A L E X A M I N A T I O N Number of Exam Pages: (including this cover sheet( Spring 2011 April 4, 2011 ( 5 ) Time Allowed: ( 1.5 ) Hours Student

More information

INSTRUCTIONS TO CANDIDATES

INSTRUCTIONS TO CANDIDATES NATIONAL UNIVERSITY OF SINGAPORE SCHOOL OF COMPUTING FINAL ASSESSMENT FOR Semester 1 AY2017/2018 CS2030 Programming Methodology II November 2017 Time Allowed 2 Hours INSTRUCTIONS TO CANDIDATES 1. This

More information

What is an Iterator? An iterator is an abstract data type that allows us to iterate through the elements of a collection one by one

What is an Iterator? An iterator is an abstract data type that allows us to iterate through the elements of a collection one by one Iterators What is an Iterator? An iterator is an abstract data type that allows us to iterate through the elements of a collection one by one 9-2 2-2 What is an Iterator? An iterator is an abstract data

More information

Testpassport. T e s tpas s port.

Testpassport. T e s tpas s port. Testpassport T e s tpas s port http://www.testpassport.kr Exam : 1Z0-851 Title : Java Standard Edition 6 Programmer Certified Professional Exam Version : Demo 1 / 11 1.Given a pre-generics implementation

More information

Oracle 1Z Java Standard Edition 5 Programmer Certified Professional.

Oracle 1Z Java Standard Edition 5 Programmer Certified Professional. Oracle 1Z0-853 Java Standard Edition 5 Programmer Certified Professional https://killexams.com/pass4sure/exam-detail/1z0-853 QUESTION: 351 12. NumberFormat nf = NumberFormat.getInstance(); 13. nf.setmaximumfractiondigits(4);

More information

CS 61B Discussion 5: Inheritance II Fall 2018

CS 61B Discussion 5: Inheritance II Fall 2018 CS 61B Discussion 5: Inheritance II Fall 2018 1 Inheritance Practice public class Q { public void a() { System.out.println("Q.a"); public void b() { a(); public void c() { public void d() { public static

More information

01. Which of the following statement describes dynamic resizing as is applies to the ArrayList class?

01. Which of the following statement describes dynamic resizing as is applies to the ArrayList class? Exposure Java Chapter 11 Multiple Choice Test ArrayList Class DO NOT WRITE ON THIS TEST This test includes program segments, which are not complete programs. Answer such questions with the assumption that

More information

CSCI 136 Written Exam #1 Fundamentals of Computer Science II Spring 2014

CSCI 136 Written Exam #1 Fundamentals of Computer Science II Spring 2014 CSCI 136 Written Exam #1 Fundamentals of Computer Science II Spring 2014 Name: This exam consists of 5 problems on the following 6 pages. You may use your double- sided hand- written 8 ½ x 11 note sheet

More information

First Name Last Name ID#

First Name Last Name ID# CIS 265 Sect 01 - V. Matos Exam-2 Spring-2015 First Name Last Name ID# (15 pts) MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question. 1) In the following

More information

Inheritance. Notes Chapter 6 and AJ Chapters 7 and 8

Inheritance. Notes Chapter 6 and AJ Chapters 7 and 8 Inheritance Notes Chapter 6 and AJ Chapters 7 and 8 1 Inheritance you know a lot about an object by knowing its class for example what is a Komondor? http://en.wikipedia.org/wiki/file:komondor_delvin.jpg

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

CMSC 433 Section 0101 Fall 2012 Midterm Exam #1

CMSC 433 Section 0101 Fall 2012 Midterm Exam #1 Name: CMSC 433 Section 0101 Fall 2012 Midterm Exam #1 Directions: Test is closed book, closed notes. Answer every question; write solutions in spaces provided. Use backs of pages for scratch work. Good

More information

Oracle 1Z0-851 Java Standard Edition 6 Programmer Certified Professional Exam

Oracle 1Z0-851 Java Standard Edition 6 Programmer Certified Professional Exam Oracle 1Z0-851 Java Standard Edition 6 Programmer Certified Professional Exam 1 QUESTION: 1 Given a pre-generics implementation of a method: 11. public static int sum(list list) { 12. int sum = 0; 13.

More information

CMSC 132: Object-Oriented Programming II

CMSC 132: Object-Oriented Programming II CMSC 132: Object-Oriented Programming II Object-Oriented Programming Intro Department of Computer Science University of Maryland, College Park Object-Oriented Programming (OOP) Approach to improving software

More information

publicvoid set(objectobject){ this. object =object;} public Objectget(){ return object;}

publicvoid set(objectobject){ this. object =object;} public Objectget(){ return object;} 1. Consider the following code (Oracle): publicclass Bucket{ private Object object ; publicvoid set(objectobject){ this. object =object; public Objectget(){ return object; Which of the following is an

More information

JAVA V Assertions Java, winter semester

JAVA V Assertions Java, winter semester JAVA Assertions 1 Assertion since Java 1.4 the statement with a boolean expression a developer supposes that the expression is always satisfied (evaluates to true) if it is evaluated to false -> error

More information

mith College Computer Science Sets and Hashing CSC212 Fall 2014 Dominique Thiébaut

mith College Computer Science Sets and Hashing CSC212 Fall 2014 Dominique Thiébaut mith College Computer Science Sets and Hashing CSC22 Fall 204 Dominique Thiébaut dthiebaut@smith.edu The Problem: Large amount of live tweets Want the list of all tweeters Each only listed once What data

More information

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

C212 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 information

CSCI-142 Exam 1 Review September 25, 2016 Presented by the RIT Computer Science Community

CSCI-142 Exam 1 Review September 25, 2016 Presented by the RIT Computer Science Community CSCI-12 Exam 1 Review September 25, 2016 Presented by the RIT Computer Science Community http://csc.cs.rit.edu 1. Provide a detailed explanation of what the following code does: 1 public boolean checkstring

More information

Practice exam for CMSC131-04, Fall 2017

Practice exam for CMSC131-04, Fall 2017 Practice exam for CMSC131-04, Fall 2017 Q1 makepalindrome - Relevant topics: arrays, loops Write a method makepalidrome that takes an int array, return a new int array that contains the values from the

More information

Inheritance (Part 5) Odds and ends

Inheritance (Part 5) Odds and ends Inheritance (Part 5) Odds and ends 1 Static Methods and Inheritance there is a significant difference between calling a static method and calling a non-static method when dealing with inheritance there

More information

Chapter 11: Collections and Maps

Chapter 11: Collections and Maps Chapter 11: Collections and Maps Implementing the equals(), hashcode() and compareto() methods A Programmer's Guide to Java Certification (Second Edition) Khalid A. Mughal and Rolf W. Rasmussen Addison-Wesley,

More information

FAQ: Classes & Objects

FAQ: Classes & Objects Question 1: How do I define a class as a data type? Answer 1: Data types in Java can be simple data types such as integers and floating point numbers. Data types can also be complex, collecting many different

More information

CS 1331 Exam 3 Practice

CS 1331 Exam 3 Practice CS 1331 Exam 3 Practice Name (print clearly): Signature: GT account username (gtg, gth, msmith3, etc): Signing signifies you are aware of and in accordance with the Academic Honor Code of Georgia Tech.

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

PASS4TEST IT 인증시험덤프전문사이트

PASS4TEST IT 인증시험덤프전문사이트 PASS4TEST IT 인증시험덤프전문사이트 http://www.pass4test.net 일년동안무료업데이트 Exam : 1z0-809 Title : Java SE 8 Programmer II Vendor : Oracle Version : DEMO Get Latest & Valid 1z0-809 Exam's Question and Answers 1 from

More information

Test 1: CompSci Exam 1 Solutions

Test 1: CompSci Exam 1 Solutions Test 1: CompSci 100 - Exam 1 Solutions Michael Hewner 2/17/2012 Name: Netid (print clearly): Honor code acknowledgement (signature): value grader grade Question 1: Algorithms 1 Question 2: Algorithms 2

More information

CS 1331 Fall 2016 Exam 3 Part 1 ANSWER KEY

CS 1331 Fall 2016 Exam 3 Part 1 ANSWER KEY CS 1331 Fall 2016 Exam 3 Part 1 Fall 2016 ANSWER KEY Failure to properly fill in the information on this page will result in a deduction of up to 5 points from your exam score. Signing signifies you are

More information

CMPS 290G Topics in Software Engineering Winter 2004 Software Validation and Defect Detection Homework 5

CMPS 290G Topics in Software Engineering Winter 2004 Software Validation and Defect Detection Homework 5 CMPS 290G Topics in Software Engineering Winter 2004 Software Validation and Defect Detection Homework 5 Due: by email to cormac@cs.ucsc.edu before or on 18 March 2004 This homework is in the form of a

More information

JAVA V Source files Java, winter semester

JAVA V Source files Java, winter semester JAVA Source files 17.10.2017 1 Unicode programs ~ Unicode comments, identifiers, char and string constants the rest is in ASCII (

More information

QUIZ 2 Introduction to Computer Science (COMP 250) Mon. March 2, 2009 Professor Michael Langer

QUIZ 2 Introduction to Computer Science (COMP 250) Mon. March 2, 2009 Professor Michael Langer QUIZ 2 Introduction to Computer Science (COMP 250) Mon. March 2, 2009 Professor Michael Langer STUDENT NAME: ID: The exam consists of five questions. There are a total of 10 points. You may use the back

More information

Full file at

Full file at Chapter 1 Primitive Java Weiss 4 th Edition Solutions to Exercises (US Version) 1.1 Key Concepts and How To Teach Them This chapter introduces primitive features of Java found in all languages such as

More information

Following is the general form of a typical decision making structure found in most of the programming languages:

Following is the general form of a typical decision making structure found in most of the programming languages: Decision Making Decision making structures have one or more conditions to be evaluated or tested by the program, along with a statement or statements that are to be executed if the condition is determined

More information

CS 1331 Exam 3 Practice ANSWER KEY

CS 1331 Exam 3 Practice ANSWER KEY CS 1331 Exam 3 Practice ANSWER KEY Signing signifies you are aware of and in accordance with the Academic Honor Code of Georgia Tech. Calculators and cell phones are NOT allowed. Note This is an object-oriented

More information

Data Structures. Data structures. Data structures. What is a data structure? Simple answer: a collection of data equipped with some operations.

Data 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 information

d. If a is false and b is false then the output is "ELSE" Answer?

d. If a is false and b is false then the output is ELSE Answer? Intermediate Level 1) Predict the output for the below code: public void foo( boolean a, boolean b) if( a ) System.out.println("A"); if(a && b) System.out.println( "A && B"); if (!b ) System.out.println(

More information

09/02/2013 TYPE CHECKING AND CASTING. Lecture 5 CS2110 Spring 2013

09/02/2013 TYPE CHECKING AND CASTING. Lecture 5 CS2110 Spring 2013 1 TYPE CHECKING AND CASTING Lecture 5 CS2110 Spring 2013 1 Type Checking 2 Java compiler checks to see if your code is legal Today: Explore how this works What is Java doing? Why What will Java do if it

More information

Distributed Systems Recitation 1. Tamim Jabban

Distributed Systems Recitation 1. Tamim Jabban 15-440 Distributed Systems Recitation 1 Tamim Jabban Office Hours Office 1004 Tuesday: 9:30-11:59 AM Thursday: 10:30-11:59 AM Appointment: send an e-mail Open door policy Java: Object Oriented Programming

More information

Solutions to Quiz 1 (March 14, 2016)

Solutions to Quiz 1 (March 14, 2016) MIT 6.005: Software Construction Max Goldman revised Wednesday 16 th March, 2016, 14:08 Solutions to Quiz 1 (March 14, 2016) Problem 1 (Multiple Choice) (20 points). (a) Which of the following must be

More information

Lab5. Wooseok Kim

Lab5. Wooseok Kim Lab5 Wooseok Kim wkim3@albany.edu www.cs.albany.edu/~wooseok/201 Question Answer Points 1 A or B 8 2 A 8 3 D 8 4 20 5 for class 10 for main 5 points for output 5 D or E 8 6 B 8 7 1 15 8 D 8 9 C 8 10 B

More information

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

CIS 1068 Program Design and Abstraction Spring2016 Midterm Exam 1. Name SOLUTION CIS 1068 Program Design and Abstraction Spring2016 Midterm Exam 1 Name SOLUTION Page Points Score 2 15 3 8 4 18 5 10 6 7 7 7 8 14 9 11 10 10 Total 100 1 P age 1. Program Traces (41 points, 50 minutes)

More information

Which code fragment must be inserted at line 6 to enable the code to compile?

Which code fragment must be inserted at line 6 to enable the code to compile? Volume: 216 Questions Question No : 1 Which code fragment cause a compilation error? A. flat flt = 100F; B. float flt = (float) 1_11.00; C. float flt = 100; D. double y1 = 203.22; floatflt = y1 E. int

More information

AP CS Unit 7: Interfaces. Programs

AP CS Unit 7: Interfaces. Programs AP CS Unit 7: Interfaces. Programs You cannot use the less than () operators with objects; it won t compile because it doesn t always make sense to say that one object is less than

More information

1. Answer as shown or -2 unless question allows partial credit. No points off for differences in spacing, capitalization, commas, and braces

1. Answer as shown or -2 unless question allows partial credit. No points off for differences in spacing, capitalization, commas, and braces CS314 Fall 2012 Midterm 2 Solution and Grading Criteria. Grading acronyms: AIOBE - Array Index out of Bounds Exception may occur BOD - Benefit of the Doubt. Not certain code works, but, can't prove otherwise

More information

CS-140 Fall 2017 Test 2 Version A Nov. 29, 2017

CS-140 Fall 2017 Test 2 Version A Nov. 29, 2017 CS-140 Fall 2017 Test 2 Version A Nov. 29, 2017 Name: 1. (10 points) For the following, Check T if the statement is true, the F if the statement is false. (a) T F : An interface defines the list of fields

More information

1- Differentiate between extends and implements keywords in java? 2- What is wrong with this code:

1- Differentiate between extends and implements keywords in java? 2- What is wrong with this code: 1- Differentiate between extends and implements keywords in java? 2- What is wrong with this code: public double getsalary() double basesalary = getsalary(); return basesalary + bonus; 3- What does the

More information

MODULE 6q - Exceptions

MODULE 6q - Exceptions MODULE 6q - Exceptions THE TRY-CATCH CONSTRUCT Three different exceptions are referred to in the program below. They are the ArrayIndexOutOfBoundsException which is built-into Java and two others, BadLuckException

More information

Sun Certified Programmer for the Java 2 Platform. SE6.0

Sun Certified Programmer for the Java 2 Platform. SE6.0 Sun Certified Programmer for the Java 2 Platform. SE6.0 Version 4.0 QUESTION NO: 1 Given a pre-generics implementation of a method: 11. public static int sum(list list) { 12. int sum = 0; 13. for ( Iterator

More information

Recitation: Loop Jul 7, 2008

Recitation: Loop Jul 7, 2008 Nested Loop Recitation: Loop Jul 7, 2008 1. What is the output of the following program? Use pen and paper only. The output is: ****** ***** **** *** ** * 2. Test this program in your computer 3. Use "for

More information

COMP 110 Programming Exercise: Simulation of the Game of Craps

COMP 110 Programming Exercise: Simulation of the Game of Craps COMP 110 Programming Exercise: Simulation of the Game of Craps Craps is a game of chance played by rolling two dice for a series of rolls and placing bets on the outcomes. The background on probability,

More information

Name Section Number. CS210 Exam #4 *** PLEASE TURN OFF ALL CELL PHONES*** Practice

Name Section Number. CS210 Exam #4 *** PLEASE TURN OFF ALL CELL PHONES*** Practice Name Section Number CS210 Exam #4 *** PLEASE TURN OFF ALL CELL PHONES*** Practice All Sections Bob Wilson OPEN BOOK/OPEN NOTES You will have all 90 minutes until the start of the next class period. Spend

More information

CSE 331 Winter 2016 Midterm Solution

CSE 331 Winter 2016 Midterm Solution CSE 331 Winter 2016 Midterm Solution Name There are 7 questions worth a total of 100 points. Please budget your time so that you get to all of the questions. Keep your answers concise. The exam is closed

More information

INSTRUCTIONS TO CANDIDATES

INSTRUCTIONS TO CANDIDATES NATIONAL UNIVERSITY OF SINGAPORE SCHOOL OF COMPUTING MIDTERM ASSESSMENT FOR Semester 2 AY2017/2018 CS2030 Programming Methodology II March 2018 Time Allowed 90 Minutes INSTRUCTIONS TO CANDIDATES 1. This

More information

CS1083 Week 2: Arrays, ArrayList

CS1083 Week 2: Arrays, ArrayList CS1083 Week 2: Arrays, ArrayList mostly review David Bremner 2018-01-08 Arrays (1D) Declaring and using 2D Arrays 2D Array Example ArrayList and Generics Multiple references to an array d o u b l e prices

More information

IT 313 Advanced Application Development

IT 313 Advanced Application Development Page 1 of 9 IT 313 Advanced Application Development Midterm Exam February, 12, 2018 Name Part A. Multiple Choice Questions. Answer all questions. Optional: supply a reason or show work for partial credit

More information

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

Birkbeck (University of London) Software and Programming 1 In-class Test Mar Answer ALL Questions Birkbeck (University of London) Software and Programming 1 In-class Test 2.1 16 Mar 2017 Student Name Student Number Answer ALL Questions 1. What output is produced when the following Java program fragment

More information

MIT AITI Lecture 18 Collections - Part 1

MIT AITI Lecture 18 Collections - Part 1 MIT AITI 2004 - Lecture 18 Collections - Part 1 Collections API The package java.util is often called the "Collections API" Extremely useful classes that you must understand to be a competent Java programmer

More information

Distributed Systems Recitation 1. Tamim Jabban

Distributed Systems Recitation 1. Tamim Jabban 15-440 Distributed Systems Recitation 1 Tamim Jabban Office Hours Office 1004 Sunday, Tuesday: 9:30-11:59 AM Appointment: send an e-mail Open door policy Java: Object Oriented Programming A programming

More information

INTRODUCTION TO SOFTWARE SYSTEMS (COMP1110/COMP1140/COMP1510/COMP6710)

INTRODUCTION TO SOFTWARE SYSTEMS (COMP1110/COMP1140/COMP1510/COMP6710) Important notice: This document is a sample exam. The final exam will differ from this exam in numerous ways. The purpose of this sample exam is to provide students with access to an exam written in a

More information

Chair of Software Engineering. Languages in Depth Series: Java Programming. Prof. Dr. Bertrand Meyer. Exercise Session 10

Chair of Software Engineering. Languages in Depth Series: Java Programming. Prof. Dr. Bertrand Meyer. Exercise Session 10 Chair of Software Engineering Languages in Depth Series: Java Programming Prof. Dr. Bertrand Meyer Exercise Session 10 Today s Exercise Session Pattern of the Day Proxy Quizzes 2 Proxy Pattern Structural

More information

Object Oriented Programming. Java-Lecture 6 - Arrays

Object Oriented Programming. Java-Lecture 6 - Arrays Object Oriented Programming Java-Lecture 6 - Arrays Arrays Arrays are data structures consisting of related data items of the same type In Java arrays are objects -> they are considered reference types

More information

Exam 1 Prep. Dr. Demetrios Glinos University of Central Florida. COP3330 Object Oriented Programming

Exam 1 Prep. Dr. Demetrios Glinos University of Central Florida. COP3330 Object Oriented Programming Exam 1 Prep Dr. Demetrios Glinos University of Central Florida COP3330 Object Oriented Programming Progress Exam 1 is a Timed Webcourses Quiz You can find it from the "Assignments" link on Webcourses choose

More information

CSC 240 Computer Science III Spring 2018 Midterm Exam. Name

CSC 240 Computer Science III Spring 2018 Midterm Exam. Name CSC 240 Computer Science III Spring 2018 Midterm Exam Name Page Points Score 2 9 4-6 53 7-10 38 Total 100 1 P age 1. Tracing programs (1 point each value): For each snippet of Java code on the left, write

More information

Chair of Software Engineering. Java and C# in Depth. Prof. Dr. Bertrand Meyer. Exercise Session 7. Nadia Polikarpova

Chair of Software Engineering. Java and C# in Depth. Prof. Dr. Bertrand Meyer. Exercise Session 7. Nadia Polikarpova Chair of Software Engineering Java and C# in Depth Prof. Dr. Bertrand Meyer Exercise Session 7 Nadia Polikarpova Quiz 1: Does it compile? (Java) public class MyException extends Exception { Checked exception...

More information

Array. Array Declaration:

Array. Array Declaration: Array Arrays are continuous memory locations having fixed size. Where we require storing multiple data elements under single name, there we can use arrays. Arrays are homogenous in nature. It means and

More information

Class definition. complete definition. public public class abstract no instance can be created final class cannot be extended

Class definition. complete definition. public public class abstract no instance can be created final class cannot be extended JAVA Classes Class definition complete definition [public] [abstract] [final] class Name [extends Parent] [impelements ListOfInterfaces] {... // class body public public class abstract no instance can

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

Language Features. 1. The primitive types int, double, and boolean are part of the AP

Language Features. 1. The primitive types int, double, and boolean are part of the AP Language Features 1. The primitive types int, double, and boolean are part of the AP short, long, byte, char, and float are not in the subset. In particular, students need not be aware that strings are

More information

Java Bytecode (binary file)

Java Bytecode (binary file) Java is Compiled Unlike Python, which is an interpreted langauge, Java code is compiled. In Java, a compiler reads in a Java source file (the code that we write), and it translates that code into bytecode.

More information

COMP 250: Java Programming I. Carlos G. Oliver, Jérôme Waldispühl January 17-18, 2018 Slides adapted from M. Blanchette

COMP 250: Java Programming I. Carlos G. Oliver, Jérôme Waldispühl January 17-18, 2018 Slides adapted from M. Blanchette COMP 250: Java Programming I Carlos G. Oliver, Jérôme Waldispühl January 17-18, 2018 Slides adapted from M. Blanchette Variables and types [Downey Ch 2] Variable: temporary storage location in memory.

More information