Java for Non Majors. Final Study Guide. April 26, You will have an opportunity to earn 20 extra credit points.

Similar documents
Java for Non Majors Spring 2018

Introduction to Programming Using Java (98-388)

Mathematics/Science Department Kirkwood Community College. Course Syllabus. Computer Science CSC142 1/10

COP 3014: Fall Final Study Guide. December 5, You will have an opportunity to earn 15 extra credit points.

This page intentionally left blank

CS 251 Intermediate Programming Methods and Classes

CS 251 Intermediate Programming Methods and More

Reviewing for the Midterm Covers chapters 1 to 5, 7 to 9. Instructor: Scott Kristjanson CMPT 125/125 SFU Burnaby, Fall 2013

15CS45 : OBJECT ORIENTED CONCEPTS

Syllabus & Curriculum for Certificate Course in Java. CALL: , for Queries

5/23/2015. Core Java Syllabus. VikRam ShaRma

F1 A Java program. Ch 1 in PPIJ. Introduction to the course. The computer and its workings The algorithm concept

Logistics. Final Exam on Friday at 3pm in CHEM 102


Building Java Programs


Chapter 3 Syntax, Errors, and Debugging. Fundamentals of Java

MyProgram m i ng Lab. get with the programming. Through the power of practice and immediate personalized

Argument Passing All primitive data types (int etc.) are passed by value and all reference types (arrays, strings, objects) are used through refs.

Course Text. Course Description. Course Objectives. StraighterLine Introduction to Programming in C++

Computer Science II (20082) Week 1: Review and Inheritance

Curriculum Map Grade(s): Subject: AP Computer Science

CS Exam 1 Review Suggestions

1 Epic Test Review 2 Epic Test Review 3 Epic Test Review 4. Epic Test Review 5 Epic Test Review 6 Epic Test Review 7 Epic Test Review 8

First IS-A Relationship: Inheritance

OOPS Viva Questions. Object is termed as an instance of a class, and it has its own state, behavior and identity.

AP Computer Science Chapter 10 Implementing and Using Classes Study Guide

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

Absolute C++ Walter Savitch

Rules and syntax for inheritance. The boring stuff

Java for Programmers Course (equivalent to SL 275) 36 Contact Hours

Computer Science II (20073) Week 1: Review and Inheritance

CONTENTS. PART 1 Structured Programming 1. 1 Getting started 3. 2 Basic programming elements 17

Objective Questions. BCA Part III Paper XIX (Java Programming) page 1 of 5

TeenCoder : Java Programming (ISBN )

Weiss Chapter 1 terminology (parenthesized numbers are page numbers)

Full file at

UNIT 3 ARRAYS, RECURSION, AND COMPLEXITY CHAPTER 11 CLASSES CONTINUED

The Sun s Java Certification and its Possible Role in the Joint Teaching Material

Lab5. Wooseok Kim

CHAPTER 7 OBJECTS AND CLASSES

Programming Exercise 14: Inheritance and Polymorphism

C# Programming for Developers Course Labs Contents

Name of subject: JAVA PROGRAMMING Subject code: Semester: V ASSIGNMENT 1

Fall 2017 CISC124 9/16/2017

DHANALAKSHMI SRINIVASAN COLLEGE OF ENGINEERING AND TECHNOLOGY ACADEMIC YEAR (ODD SEM)

Introduce C# as Object Oriented programming language. Explain, tokens,

C++ Important Questions with Answers

More Relationships Between Classes

PESIT Bangalore South Campus

Problem Solving with C++

Chapter 2 Using Data. Instructor s Manual Table of Contents. At a Glance. Overview. Objectives. Teaching Tips. Quick Quizzes. Class Discussion Topics

APCS Semester #1 Final Exam Practice Problems

Course Outline. Introduction to java

COP 3330 Final Exam Review

Introduction to Visual Basic and Visual C++ Introduction to Java. JDK Editions. Overview. Lesson 13. Overview

HAS-A Relationship. Association is a relationship where all objects have their own lifecycle and there is no owner.

Programming II (CS300)

CSCE 145 Exam 2 Review No Answers. This exam totals to 100 points. Follow the instructions. Good luck!

Come & Join Us at VUSTUDENTS.net

Core Java - SCJP. Q2Technologies, Rajajinagar. Course content

BCIS 3630 Dr. GUYNES SPRING 2018 TUESDAY SECTION [JAN version] GRADER COURSE WEBSITE

Virtualians.ning.pk. 2 - Java program code is compiled into form called 1. Machine code 2. native Code 3. Byte Code (From Lectuer # 2) 4.

AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS

Overview. Lecture 7: Inheritance and GUIs. Inheritance. Example 9/30/2008

Object Oriented Programming: In this course we began an introduction to programming from an object-oriented approach.

C ONTENTS PART I FUNDAMENTALS OF PROGRAMMING 1. and Java 3. Chapter 1 Introduction to Computers, Programs,

(800) Toll Free (804) Fax Introduction to Java and Enterprise Java using Eclipse IDE Duration: 5 days

Java Programming Training for Experienced Programmers (5 Days)

Computer Science 2 Lecture 4 Inheritance: Trinidad Fruit Stand 02/15/2014 Revision : 1.7

CompuScholar, Inc. 9th - 12th grades

CMSC 331 Second Midterm Exam

Contents. Figures. Tables. Examples. Foreword. Preface. 1 Basics of Java Programming 1. xix. xxi. xxiii. xxvii. xxix

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

Contents Chapter 1 Introduction to Programming and the Java Language

S.No Question Blooms Level Course Outcome UNIT I. Programming Language Syntax and semantics

HAS-A Relationship. If A uses B, then it is an aggregation, stating that B exists independently from A.

EECS168 Exam 3 Review

TOPIC 2 INTRODUCTION TO JAVA AND DR JAVA

Block I Unit 2. Basic Constructs in Java. AOU Beirut Computer Science M301 Block I, unit 2 1

CGS 2405 Advanced Programming with C++ Course Justification

Java Overview An introduction to the Java Programming Language

3. Convert 2E from hexadecimal to decimal. 4. Convert from binary to hexadecimal

WA1278 Introduction to Java Using Eclipse

More About Objects. Zheng-Liang Lu Java Programming 255 / 282

CONTENTS. Chapter 1 Getting Started with Java SE 6 1. Chapter 2 Exploring Variables, Data Types, Operators and Arrays 13

Supporting Materials

Polymorphism. return a.doublevalue() + b.doublevalue();

Lesson 10A OOP Fundamentals. By John B. Owen All rights reserved 2011, revised 2014

Cpt S 122 Data Structures. Course Review Midterm Exam # 2

CORE JAVA TRAINING COURSE CONTENT

CHAPTER 7 OBJECTS AND CLASSES

3D Graphics Programming Mira Costa High School - Class Syllabus,

College Board. AP CS A Labs Magpie, Elevens, and Picture Lab. New York: College Entrance Examination Board, 2013.

Foundations of object orientation

Declarations and Access Control SCJP tips

Inheritance and Polymorphism

CS 251 Intermediate Programming Inheritance

Object Oriented Programming with Java. Unit-1

A Short Summary of Javali

Transcription:

Java for Non Majors Final Study Guide April 26, 2017 The test consists of 1. Multiple choice questions 2. Given code, find the output 3. Code writing questions 4. Code debugging question 5. Short answer questions You will have an opportunity to earn 20 extra credit points. Please try and attempt all questions. You get points for trying. The test is cumulative, but focuses on topics introduced before the second midterm. Anything from the slides / homeworks / quizzes is fair game. Code debugging is mostly syntax based (missing brackets, etc.) Topics to study Basics of Java Programming. You will be expected to be familiar with Java Syntax, the basic components of a Java program, compiling and running code and the tools involved, etc. Questions will draw from (but not be limited to) the following topics: Java reserved words. Data types, variables and type conversions. Operators and operator precedence. Console I/O. Basic input output Printing using the System class methods - println, print and printf. Reading in data from the console using the Scanner class. Selection and Repetition. Regular sequential execution of code. Logical operators and short circuit evaluations. Selection statement - if, if-else, if-else ladders, switch structure (including case labels, use of break and continue) 1

Loops - while, do-while and for loops, enhanced for loops, choosing loops most suited for a particular task. Java Methods. Strings Arrays Method syntax - declaring and defining methods. Modifiers, return types and parameter lists. Pass by value and pass by reference. Method overloading. String comparison. Using methods of the String class Declaring, initializing and using arrays of primitive types. Passing arrays as parameters to methods and returning arrays from methods. Multi-dimensional arrays. Classes and Objects Creating an object of a pre-existing class and using the available methods. Access Modifiers - public, private and protected. Defining a class - data attributes, constructors, accessor and mutator methods, instance methods. Instantiating a class (creating an object), and using instance methods. Difference between static and instance methods. Passing objects as parameters to methods and returning objects from methods. The this keyword. Arrays of objects. Inheritance, Interfaces and Polymorphism Concept of base (super) and derived (sub) classes. The super() keyword. Method overriding. The class Object Abstract Classes The concept of dynamic binding. Casting classes Interfaces Java Exceptions Types of exceptions. Claiming, throwing and catching exceptions. GUI programming and Graphics Basic Graphics Classes in Java (Swing and AWT). The paint() methods, and the Graphics, Color and Polygon classes. 2

Sample Questions 1. General Instructions The multiple choice questions and short answer questions will pretty much be like the questions on the midterms. The code debugging question will also follow the same pattern. You only need to point out the syntax and semantic errors. You don t need to fix typos in String literals, or attempt to fix the logic. Basically, you only need to fix the stuff that the compiler will complain about. Some samples for the code writing questions are included in the study guide. Please note that the sample questions are of the same difficulty level as the questions on the test. That is the only similarity between the questions here and those on the test. You will be expected to solve a different problem on the test. The Sample Runs provided here and on the test are samples. They are just a single run of the program. Your solution should work for all legal inputs. Please do not hard code your solution (think that the sample is the only possible input) to the sample run. The sample is just provided to clarify the requirement. For example, if the sample run says N=4, it does not mean N is 4 all the time. It just happens to be 4 this once. It can be any integer. 2.Examples 1. Which of the following is NOT a Java reserved word? (a) public (b) static (c) void (d) main 2. Evaluate the following expression. x = 5, y = 15, z = 3 (All integers) x * 4 + y / 2 % z (a) 21 (b) 2 (c) 2.5 (d) None of the above 3. A Java variable can begin with (a) A letter (b) underscore (c) $ sign (d) All of the above 3

4. Which of the following is NOT a Java access specifier? (a) public (b) private (c) abstract (d) protected 5. The class Coffee has a single data attribute price. Which of the following methods can be private? (a) void calctax() (b) Coffee(double p) (c) void setprice (double p) (d) double getprice() 6. A variable declared inside a block is available (a) throughout the program (b) only in that block (c) only in that class (d) only in that method 7. An object consists of (a) Name (b) Attributes (c) Methods (d) All of the above 8. A class is a single instance of an object (a) True (b) False 9. IndexOutOfBoundsException is a (a) Normal Exceptions (checked exceptions) (b) Runtime Exceptions (unchecked exceptions) (c) Error 10. FileNotFoundException is a (a) Normal Exceptions (checked exceptions) (b) Runtime Exceptions (unchecked exceptions) (c) Error 11. Animal s1, s2, s3; // Animal is the base class s2 = new Bird(); Bird c = new Bird(); // Bird is a derived class Please choose all correct options below. 4

(a) s1 = c; (b) (c) s1 = (Animal)c; s3 = new Bird(); (d) c = s2; (e) c = (Bird)s2; 12. Which of the following is not a container? (a) JFrame (b) JPanel (c) JDialog (d) JMenu 13. How do you do exception handling? 14. What is the Helper classes? Give 3 examples for them 15. What are the Simple Dialog Box types? Explain each of them with a few sentence 3. Code Writing: Loops Write a Java method called armstrong to print all the Armstrong Numbers in a given range. This method accepts 2 integer parameters - start and end and returns nothing. An Armstrong Number is a 3 digit number where the sum of the cubes of the individual digits of the number equals the number itself. For example, 371 is an Armstrong Number, since 3 3 + 7 3 + 1 3 = 27 + 343 + 1 = 371. Sample Run: (start = 100, end = 999) The Armstrong Numbers between 100 and 999 are: 153 370 371 407 Solution: Please note that only the method is required. You need not write the entire program. 4. Code Writing: String Manipulation Write a Java method called insert3 that reads a series of strings from the user and prints them after inserting the string blue at the third index of the given string. The method accepts a single integer parameter N that denotes the number of strings. The function returns nothing. The strings entered by the user will always be at least 4 characters long. You need to test for that. Sample Run: (N = 4) Enter the 4 strings: Hello World Helbluelo World To infinity and beyond To blueinfinity and beyond I Wumbo You Wumbo I Wblueumbo You Wumbo Java Programming Javbluea Programming 5

Solution: Once again, we only need to write the method, not the entire class. You can assume that all the necessary libraries have been imported. You can make this assumption of the test as well. 5. Code Writing: Inheritance + Array of Objects Write a Java program with the following requirements. Write a class called Drink. The class has an integer attribute called size that holds the size of the drink in ounces. The class also has a parametrized constructor and a method called print that prints the size. Write a class called Coffee that inherits from Drink. The class has an integer attribute called numshots that denotes number of espresso shots in the drink. The class also has a parametrized constructor and a method called print that overrides the base class method to print both the size and the number of shots. Write a class called Beer that inherits from Drink. The class has a double attribute called percentalcohol that denotes percentage of alcohol content in the drink. The class also has a parametrized constructor and a method called print that overrides the base class method to print both the size and the percentage of alcohol. Write a class called ManyDrinks. This call just contains the main method. In the main method, create an array of Drink of size 4. The first 2 elements are of type Coffee, and the last 2 are Beer. Give the drinks values of your choice. Then invoke the print method for each of them. 6