Java Simple Data Types

Similar documents
Java Simple Data Types

Key Java Simple Data Types

JAVA OPERATORS GENERAL

Java provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following groups:

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

Programming Basics. Digital Urban Visualization. People as Flows. ia

Prof. Navrati Saxena TA: Rochak Sachan

Java provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following groups:

Selenium Class 9 - Java Operators

bitwise inclusive OR Logical logical AND && logical OR Ternary ternary? : Assignment assignment = += -= *= /= %= &= ^= = <<= >>= >>>=

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

Lab5. Wooseok Kim

Fall CS 101: Test 2 Name UVA ID. Grading. Page 1 / 4. Page3 / 20. Page 4 / 13. Page 5 / 10. Page 6 / 26. Page 7 / 17.

(A) 99 ** (B) 100 (C) 101 (D) 100 initial integers plus any additional integers required during program execution

Computational Expression

Lab5. Wooseok Kim

Building Java Programs

Building Java Programs

Datatypes, Variables, and Operations

Practice Questions for Final Exam: Advanced Java Concepts + Additional Questions from Earlier Parts of the Course

(A) 99 (B) 100 (C) 101 (D) 100 initial integers plus any additional integers required during program execution

b. Suppose you enter input from the console, when you run the program. What is the output?

Place your name tag here

1. Which of the following is the correct expression of character 4? a. 4 b. "4" c. '\0004' d. '4'

COMP 202 Java in one week

CIS 1068 Design and Abstraction Spring 2017 Midterm 1a

JAVA PROGRAMMING LAB. ABSTRACT In this Lab you will learn to define and invoke void and return java methods

Introduction to Computer Programming

More on methods and variables. Fundamentals of Computer Science Keith Vertanen

1. Find the output of following java program. class MainClass { public static void main (String arg[])

CS212 Midterm. 1. Read the following code fragments and answer the questions.

Prelim 1. CS 2110, October 1, 2015, 5:30 PM Total Question Name True Short Testing Strings Recursion

Building Java Programs

Eng. Mohammed S. Abdualal

Basic operators, Arithmetic, Relational, Bitwise, Logical, Assignment, Conditional operators. JAVA Standard Edition

Introduction to OOP with Java. Instructor: AbuKhleif, Mohammad Noor Sep 2017

Java Programming Language. 0 A history

CS 231 Data Structures and Algorithms, Fall 2016

Building Java Programs. Chapter 2: Primitive Data and Definite Loops

Wentworth Institute of Technology. Engineering & Technology WIT COMP1000. Simple Control Flow: if-else statements

CONDITIONAL EXECUTION

BASIC COMPUTATION. public static void main(string [] args) Fundamentals of Computer Science I

CS 170 Exam 1. Version: B Fall Name (as on OPUS):

Chapter III. Java Simple Data Types. Chapter III Topics

Computer Programming, I. Laboratory Manual. Experiment #2. Elementary Programming

12/22/11. Java How to Program, 9/e. Help you get started with Eclipse and NetBeans integrated development environments.

PROGRAMMING FUNDAMENTALS

CS 170 Exam 1. Version: C Fall Name (as on OPUS):

This page intentionally left blank

false, import, new 1 class Lecture2 { 2 3 "Data types, Variables, and Operators" 4

INDEX. A SIMPLE JAVA PROGRAM Class Declaration The Main Line. The Line Contains Three Keywords The Output Line

Data and Variables. Data Types Expressions. String Concatenation Variables Declaration Assignment Shorthand operators. Operators Precedence

CSE115 / CSE503 Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall Office hours:

OWEN COMPUTER SCIENCE LESSONS L2RVW4 Pg 1. Lesson 2 Review #4. Matching. Match each description to the correct data type.

Basics of Java Programming

Data Types. 1 You cannot change the type of the variable after declaration. Zheng-Liang Lu Java Programming 52 / 87

cis20.1 design and implementation of software applications I fall 2007 lecture # I.2 topics: introduction to java, part 1

Section 003 Fall CS 170 Exam 2. Name (print): Instructions:

Lecture 2. COMP1406/1006 (the Java course) Fall M. Jason Hinek Carleton University

Introduction to Computer Science Midterm 3 Fall, Points

AP COMPUTER SCIENCE A

Selected Questions from by Nageshwara Rao

Activity 1: Introduction

Term 1 Unit 1 Week 1 Worksheet: Output Solution

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

Variables Chris Piech CS106A, Stanford University. Piech, CS106A, Stanford University

Question: Total Points: Score:

Lecture 2. Examples of Software. Programming and Data Structure. Programming Languages. Operating Systems. Sudeshna Sarkar

Outline. Overview. Control statements. Classes and methods. history and advantage how to: program, compile and execute 8 data types 3 types of errors

Primitive Data, Variables, and Expressions; Simple Conditional Execution

Program Fundamentals

Chapter 3: Operators, Expressions and Type Conversion

B.V. Patel Institute of BMC & IT, UTU 2014

Operators & Expressions

More Things We Can Do With It! Overview. Circle Calculations. πr 2. π = More operators and expression types More statements

Lec 3. Compilers, Debugging, Hello World, and Variables

COMP 202 Java in one week

Methods. Eng. Mohammed Abdualal

Assoc. Prof. Dr. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved.

2.8. Decision Making: Equality and Relational Operators

CIS133J. Working with Numbers in Java

Computer Programming, I. Laboratory Manual. Experiment #7. Methods

Mth 60 Module 2 Section Signed Numbers All numbers,, and

Chapter 3 Selection Statements

THE UNIVERSITY OF WESTERN AUSTRALIA. School of Computer Science & Software Engineering CITS1001 OBJECT-ORIENTED PROGRAMMING AND SOFTWARE ENGINEERING

Entry Point of Execution: the main Method. Elementary Programming. Learning Outcomes. Development Process

Units 0 to 4 Groovy: Introduction upto Arrays Revision Guide

COMP 202. Java in one week

Recitation #2 Abstract Data Types, Collection Classes, and Linked List

Question: Total Points: Score:

DM550 / DM857 Introduction to Programming. Peter Schneider-Kamp

2.5 Another Application: Adding Integers

Midterm Exam CS 251, Intermediate Programming March 6, 2015

CS-140 Fall 2017 Test 1 Version Practice Practie for Sept. 27, Name:

1. [3 pts] What is your section number, the period your discussion meets, and the name of your discussion leader?

Data Types and the while Statement

CSC 1214: Object-Oriented Programming

INSTRUCTIONS TO CANDIDATES

Java Programming for Selenium

JAVA Ch. 4. Variables and Constants Lawrenceville Press

Transcription:

Intro to Java Unit 1 Multiple Choice Java Simple Data Types DO NOT WRITE ON THIS TEST This test includes program segments, which are not complete programs. Answer such questions with the assumption that the program segment is part of a correct program. 01. Which of the following are Java program keyword categories? (A) Reserved words, pre-defined identifiers and user-defined identifiers (B) Reserved pre-defined identifiers, reserved user-defined identifiers and library identifiers (C) void, static, println. (D) None of the above 02. Consider the two program segments below. Segment A Segment B int a; int a = 100; int b; int b = 200; a = 100; b = 200; What is true about the comparison of these two segments? (A) Segment A is correct and segment B is not correct. (B) Segment A is incorrect and segment B is correct. (C) Segment A and segment B are both correct. (D) segment A and segment B are both incorrect.

03. Consider the two program segments below. Segment A Segment B int a; int a = 100; int b; int b = 200; System.out.println(a); System.out.println(a); System.out.println(b); System.out.println(b); What is true about the comparison of these two segments? (A) Segment A is correct and segment B is not correct. (B) Segment A is incorrect and segment B is correct. (C) Segment A and segment B are both correct. (D) segment A and segment B are both incorrect. 04. Which of the following are examples of reserved words? (A) public, void and static (B) System, out and println (C) System, public and void (D) print, println and args 05. Which of the following is used to store integers? 06. Which of the following is used to store real numbers?

07. Which of the following would be ideal for storing a Middle Initial? 08. Which of the following would you need to store someone's name? 09. Which of the following can only store 2 possible values: true or false? 10. Which of the following stores 1 single character? 11. Which of the following can store words, phrases, or sentences?

12. Which of the following Java data types is the most like the Lego NXT Number data type? 13. Which of the following Java data types is the most like the Lego NXT Text data type? 14. Which of the following Java data types is the most like the Lego NXT Logic data type? 15. Which of the following are Java Keywords? (A) Reserved Words (B) Pre-defined Identifiers (C) User-defined Identifiers (D) All of the above 16. Assume x is defined as an int. Which of the following will add 1 to x? (A) x++; (B) x+=1; (C) x=x+1; (D) All of the above

17. Assume x is defined as an int. Which of the following will subtract 1 from x? (A) x--; (B) x-=1; (C) x=x-1; (D) All of the above 18. Which operator is used for multiplication? (A) + (B) (C) * (D) / (E) % 19. Which operator will find the quotient when performing division? (A) + (B) - (C) * (D) / (E) % 20. Which operator will find the remainder when performing division? (A) + (B) - (C) * (D) / (E) % 21. Assume x is defined as an int. Which of the following will double the value in x? (A) x = x + x; (B) x += x; (C) x = x * 2; (D) x *= 2; (E) All of the above

22. 7 is a(n) value. (A) char (B) double (C) int (D) String 23. 7.0 is a(n) value. (A) char (B) double (C) int (D) String 24. '7' is a(n) value. (A) char (B) double (C) int (D) String 25. "7" is a(n) value. (A) char (B) double (C) int (D) String

26. What is the output of this program? (A) 2 (B) 2.5 (C) 150 (D) 25000 (E) 250 100 27. What is the output of this program? (A) 2 (B) 2.5 (C) 150 (D) 25000 (E) 250 100 28. What is the output of this program? (A) 2 (B) 2.5 (C) 150 (D) 25000 (E) 250 100 29. What is the output of this program? (A) 2 (B) 2.5 (C) 150 (D) 25000 (E) 250 100

30. What is the output of this program? (A) John (B) John Smith (C) JohnSmith (D) Smith, John (E) John C. Smith 31. What is the output of this program? (A) John (B) John Smith (C) JohnSmith (D) Smith, John (E) John C. Smith 32. What is the output of this program? (A) John (B) John Smith (C) JohnSmith (D) Smith, John (E) John C. Smith 33. What is the output of this program? (A) John (B) John Smith (C) JohnSmith (D) Smith, John (E) John C. Smith

34. What is the output of this program? (A) 100 (B) 200 (C) 300 (D) 100200 (E) 100 200 35. What is the output of this program? (A) 100 (B) 200 (C) 300 (D) 100200 (E) 100 200 36. What is the output of this program? (A) (B) (C) No Output (D) Compiler Error 37. What is the output of this program? (A) (B) (C) No Output (D) Compiler Error

38. Which of the following is the single-line comment symbol? (A) // (B) \\ (C) /* (D) */ 39. Which of the following is the begin-multiple-line comment symbol? (A) // (B) \\ (C) /* (D) */ 40. Which of the following is the end-multiple-line comment symbol? (A) // (B) \\ (C) /* (D) */ 41. What is the value of x after this statement? int x = 3 + 7 * 5; (A) 26 (B) 38 (C) 48 (D) 50 (E) 66 42. What is the value of x after this statement? int x = 3 + (7 * 5); (A) 26 (B) 38 (C) 48 (D) 50 (E) 66

43. What is the value of x after this statement? int x = (3 + 7) * 5; (A) 26 (B) 38 (C) 48 (D) 50 (E) 66 44. What is the value of x after this statement? int x = (4 + 8) / 2; (A) 2 (B) 4 (C) 6 (D) 8 (E) 12 45. What is the value of x after this statement? int x = 4 + 8 / 2; (A) 2 (B) 4 (C) 6 (D) 8 (E) 12 46. What is the value of x after this statement? int x = 4 + (8 / 2); (A) 2 (B) 4 (C) 6 (D) 8 (E) 12

47. What is the value of x after this statement? int x = 2 / 5; (A) 0 (B) 0.4 (C) 0.5 (D) 2 (E) 2.5 48. What is the value of x after this statement? double x = 2.0 / 5.0; (A) 0 (B) 0.4 (C) 0.5 (D) 2 (E) 2.5 49. What is the output of this program segment? double PI = 3.14159; System.out.println(PI); (A) PI (B) 3.14159 (C) PI = 3.14159 (D) PI = PI (E) Compile Error 50. What is the output of this program segment? double PI = 3.14159; System.out.println("PI"); (A) PI (B) 3.14159 (C) PI = 3.14159 (D) PI = PI (E) Compile Error

51. What is the output of this program segment? double PI = 3.14159; System.out.println("PI = " + PI); (A) PI (B) 3.14159 (C) PI = 3.14159 (D) PI = PI (E) Compile Error 52. What is the output of this program segment? double PI; System.out.println(PI); (A) PI (B) 3.14159 (C) PI = 3.14159 (D) PI = PI (E) Compile Error 53. What is the output of this program segment? int q = 11; q--; q--; q--; q--; System.out.println(q); (A) 7 (B) 8 (C) 9 (D) 10 (E) 11

54. What is the output of this program segment? int q = 11; q--; q++; q--; q++; System.out.println(q); (A) 7 (B) 8 (C) 9 (D) 10 (E) 11 55. What is the output of this program segment? int q = 4; q *= 2; System.out.println(q); (A) 7 (B) 8 (C) 9 (D) 10 (E) 11 56. What is the output of this program segment? int q = 24; q /= 3; q++; System.out.println(q); (A) 7 (B) 8 (C) 9 (D) 10 (E) 11

57. What is the output of this program segment? int q = 24; q /= 4; q--; System.out.println(q); (A) 5 (B) 6 (C) 7 (D) 8 (E) 9 58. What is the output of this program segment? int a = 2; int b = 3; a++; b--; int c = a + b; System.out.println(c); (A) 5 (B) 6 (C) 7 (D) 8 (E) 9 59. What is the output of this program segment? int a = 4; int b = 3; a *= 3; b *= 2; int c = a + b; System.out.println(c); (A) 6 (B) 7 (C) 12 (D) 18 (E) 72

60. What is the output of this program segment? int a, b; a = b = 30; a /= 3; b /= 5; int c = a - b; System.out.println(c); (A) 4 (B) 6 (C) 8 (D) 10 (E) 30