ICSE Class 10 Computer Applications ( Java ) 2014 Solved Question Paper

Size: px
Start display at page:

Download "ICSE Class 10 Computer Applications ( Java ) 2014 Solved Question Paper"

Transcription

1 1 of :1 ICSE J Java for Class X Computer Applications ICSE Class 10 Computer Applications ( Java ) 014 Solved Question Paper ICSE Question Paper 014 (Solved) Computer Applications Class X SECTION A (40 Marks) Answer all questions from this Section Question 1. (a) Which of the following are valid comments? [] (i) /* comment */ (ii) /*comment (iii) //comment (iv) */ comment */ (i) and (iii) are valid comments. (i) is a multi line comment and (iii) is a single line comment. (b) What is meant by a package? Name any two Java Application Programming Interface packages. [] Related classes are grouped together as a package. A package provides namespace management and access protection. Some of the Java API packages java.lang, java,util and java,io (c) Name the primitive data type in Java that is: (i) a 64-bit integer and is used when you need a range of values wider than those provided by int. (ii) a single 16-bit Unicode character whose default value is \u0000 [] (i) long (ii) char (d) State one difference between floating point literals float and double. [] (i) Float requires 4 bytes of storage while double requires 8 bytes. (ii) Float is of single precision while double is of double precision. (e) Find the errors in the given program segment and re-write the statements correctly to assign values to an integer array. [] 1 int a = new int( 5 ); for( int i=0; i<=5; i++ ) a[i]=i; The corrected program segment is 1 int a = new int[5]; for( int i=0; i<=4; i++ ) a[i]=i; Error 1: The size of an array is specified using square brackets [] and not parentheses (). Error : Since the array is of length 5, the indices range from 0 to 4. The loop variable i is used as an index to the array and in the given program segment, it takes values from 0 to 5. a[4] would result in an ArrayIndexOutOfBoundsException. Therefore, the loop condition should be changed to i<=4. The given program segment creates an array of size 5 and stores numbers from 0 to 4 in the array. Question. (a) Operators with higher precedence are evaluated before operators with relatively lower precedence. Arrange the operators given below in order of higher precedence to lower precedence. [] (i) && (ii) % (iii) >= (iv) ++ ++, %, >=, &&

2 of :1 (b) Identify the statements listed below as assignment, increment, method invocation or object creation statements. [] (i) System.out.println( Java ); (ii) costprice = ; (iii) Car hybrid = new Car(); (iv) petrolprice++; (i) Method Invocation println() is a method of System.out. (ii) Assignment The value is being assigned to the variable costprice. (iii) Object Creation An object of type Car is created and stored in the variable hybrid. (iv) Increment The variable petrolprice is incremented. (c) Give two differences between switch statement and if-else statement. [] (i) Switch statement can be used to test only for equality of a particular variable with a given set of values while an if-else statement can be used for testing arbitrary boolean expressions. (ii) If else can handle only primitive types and String while if-else can handle all data types. (d) What is an infinite loop? Write an infinite loop statement. [] An infinite loop is a loop whose body executes continuously. Infinite Loop using while: 1 while(true) { } Infinite Loop using for 1 for( ; ;){ } Infinite loop using do-while 1 do { } while(true); (e) What is a constructor? When is it invoked? [] A constructor is a member function of a class used to perform initialization of the object. It is invoked during object creation. Question 3. (a) List the variables from those given below that are composite data types. [] (i) static int x; (ii) arr[i] = 10; (iii) obj.display(); (iv) boolean b; (v) private char chr; (vi) String str; The primitive data types in Java are byte, short, int, long, float, double, boolean and char. All other data types arrays, objects and interfaces are composite data types. (i) x is of a primitive data type (ii) arr is variable of a composite data type of type int. i can be a variable of a primitive data type (byte, short or int) or of a composite data type (Byte, Short, Integer) (iii) obj is a variable of a composite data type (iv) b is a variable of a primitive data type (v) chr is a variable of a primitive data type (vi) str is a variable of a composite data type String which is of class type (b) State the output of the following program segment: [] 1 String str1 = "great"; String str = "minds"; System.out.println(strl.substring(0,).concat(str.substring(l))); 3 System.out.println(("WH" + (strl.substring().touppercase()))); Output is 1 grinds WHEAT Explanation for first print statement:

3 3 of :1 strl.substring(0,) gives gr str.substring(l) inds The two on concatenation gives grinds Explanation for second print statement strl.substring() gives eat eat on conversion to upper case using the function touppercase() results in EAT WH on concatenation with EAT using + gives WHEAT (c) What are the final values stored in variables x and y below? [] 1 double a = ; double b = 14.74; 3 double x = Math.abs(Math.ceil(a)); 4 double y = Math.rint(Math.max(a,b)); Math.ceil() gives the smallest of all those integers that are greater than the input. So, Math.ceil(-6.35) gives -6.0 (not -6 as ceil returns a double value). Math.abs() gives the absolute value of the number i.e. removes negative sign, if present. So, Math.abs(-6.0) results in 6.0. So, x will be 6.0. Math.max(-6.35, 14.74) returns rint() returns the double value which is closest in value to the argument passed and is equal to an integer. So, Math.rint(14.74) returns So, y will hold (d) Rewrite the following program segment using the if-else statements instead of the ternary operator. [] 1 String grade = (mark >= 90)? "A" : (mark >= 80)? "B" : "C"; 1 String grade; if(marks >= 90) { 3 grade = "A"; 4 } else if( marks >= 80 ) { 5 grade = "B"; 6 } else { 7 grade = "C"; 8 } (e) Give output of the following method: [] 1 public static void main(string[] args) { int a = 5; 3 a++; 4 System.out.println(a); 5 a -= (a--) - (--a); 6 System.out.println(a); } a++ increments a from 5 to 6. The first print statement prints the value of a which is 6. a -= (a ) ( a); is equivalent to a = a ( (a ) ( a) ) a = 6 ( 6 4 ) a = 6 a = (f) What is the data type returned by the library functions: [] (i) compareto() (ii) equals() (i) int (ii) boolean (g) State the value of characteristic and mantissa when the following code is executed. [] 1 String s = "4.3756"; int n = s.indexof('.'); 3 int characteristic = Integer.parseInt(s.substring(0,n)); 4 int mantissa = Integer.valueOf(s.substring(n+1));

4 4 of :1 n = 1 characteristic = Integer.parseInt(s.substring(0,n)) = Integer.parseInt( substring(0,1)) = Integer.parseInt( 4 ) = 4 characteristic = 4 mantissa = Integer.valueOf( substring(1+1)) = Integer.valueOf( 3756 ) = 3756 mantissa = 3756 (h) Study the method and answer the given questions. [] 1 public void samplemethod() { for( int i=0; i<3; i++ ) 3 { for( int j=0; j<; j++) 4 { int number = (int)(math.random() * 10); 5 System.out.println(number); } } } (i) How many times does the loop execute? (ii) What is the range of possible values stored in the variable number? (i) The outer loop executes 3 times ( i= 0, 1, ) and for each execution of the outer loop, the inner loop executes two times ( j= 0, 1). So, the inner loop executes 3 * = 6 times (ii) Math.random() returns a value between 0 (inclusive) and 1 (exclusive). Math.random() * 10 will be in the range 0 (inclusive) and 10 (exclusive) (int)(math.random() * 10) will be in the range 0 (inclusive) and 9 (inclusive) (only integer values) (i) Consider the following class: [] (i) Name the variables for which each object of the class will have its own distinct copy. (ii) Name the variables that are common to all objects of the class. For static variables, all objects share a common copy while for non static variable, each object gets its own copy. Therefore, the answer is (i) a, b (ii) x, y 1 public class myclass { public static int x = 3, y = 4; 3 public int a =, b = 3; } (j) What will be the output when the following code segments are executed? [] (i) (ii) 1 String s = "1001"; int x = Integer.valueOf(s); 3 double y = Double.valueOf(s); 4 System.out.println("x=" +x); 5 System.out.println("y=" +y); 1 System.out.println("The King said \"Begin at the beginning!\" to me."); (i) s = 1001 x = 1001 y = Output will be 1 x=1001 y= (ii) The King said Begin at the beginning! to me. \ is an escape sequence which prints SECTION B (60 Marks) Attempt any four questions from this Section. Question 4. Define a class named moviemagic with the following description: Instance variables/data members: int year to store the year of release of a movie String title to store the title of the movie. float rating to store the popularity rating of the movie. (minimum rating = 0.0 and maximum rating = 5.0)

5 5 of :1 Member Methods: (i) moviemagic() Default constructor to initialize numeric data members to 0 and String data member to. (ii) void accept() To input and store year, title and rating. (iii) void display() To display the title of a movie and a message based on the rating as per the table below. RATING MESSAGE TO BE DISPLAYED 0.0 to.0 Flop.1 to 3.4 Semi-hit 3.5 to 4.5 Hit 4.6 to 5.0 Super Hit Write a main method to create an object of the class and call the above member methods. Program 1 import java.util.scanner; 3 public class moviemagic { 4 5 int year; 6 String title; 7 float rating; 8 9 public moviemagic() { 10 year = 0; 11 title = ""; 1 rating = 0; 13 } public void accept() { 16 Scanner scanner = new Scanner(System.in); 17 System.out.print("Enter title: "); 18 title = scanner.nextline(); 19 System.out.print("Enter year: "); 0 year = scanner.nextint(); 1 System.out.print("Enter rating: "); rating = scanner.nextfloat(); 3 } 4 5 public void display() { 6 System.out.println("Movie Title - " + title); 7 if (rating >= 0 && rating <=.0) { 8 System.out.println("Flop"); 9 } else if (rating >=.1 && rating <= 3.4) { 30 System.out.println("Semi-hit"); 31 } else if (rating >= 3.5 && rating <= 4.5) { 3 System.out.println("Hit"); 33 } else if (rating >= 4.6 && rating <= 5.0) { 34 System.out.println("Super Hit"); 35 } 36 } public static void main(string[] args) { 39 moviemagic movie = new moviemagic(); 40 movie.accept(); 41 movie.display(); 4 } } Sample Output 1 Enter title: Raja Rani Enter year: 01 3 Enter rating: Movie Title - Raja Rani 5 Super Hit Question 5. A special two-digit number is such that when the sum of its digits is added to the product of its digits, the result is equal to the original two-digit number. Example: Consider the number 59. Sum of digits = = 14 Product of its digits = 5 x 9 = 45

6 6 of :1 Sum of the sum of digits and product of digits= = 59 Write a program to accept a two-digit number. Add the sum of its digits to the product of its digits. If the value is equal to the number input, output the message Special -digit number otherwise, output the message Not a Special -digit number. We create a Scanner object and accept the input number using nextint() method. The input is stored in the variable number. It is given in the question that the input will be a two digit number. We need to extract the two digits of the number into two variables leftdigit and rightdigit. The left digit can be extracted by dividing the number by 10. (Note that number is an int and the divisor 10 is an int. So, the result will be an int and not a float i.e. we obtain only the quotient as the result). The right digit can be obtained by calculating the remainder when number is divided by 10. Let us take an example input number = 59. Then, leftdigit = number / 10 = 59 / 10 = 5 rightdigit = number % 10 = 59 % 10 = 9 Once, we have the two numbers, calculating the sum and product of the digits is easy. 1 int sumofdigits = rightdigit + leftdigit; int productofdigits = rightdigit * leftdigit; Next, we add the two variables above and store it in a new variable. 1 int sumofproductandsum = sumofdigits + productofdigits; Finally, we use if else decision statements to check if the sum of product of digits and sum of digits is same as the input number and print an appropriate message. Program 1 import java.util.scanner; 3 public class SpecialNumber { 4 5 public static void main(string[] args) { 6 Scanner scanner = new Scanner(System.in); 7 System.out.print("Enter number: "); 8 int number = scanner.nextint(); 9 int rightdigit = number % 10; 10 int leftdigit = number / 10; 11 int sumofdigits = rightdigit + leftdigit; 1 int productofdigits = rightdigit * leftdigit; 13 int sumofproductandsum = sumofdigits + productofdigits; 14 if (sumofproductandsum == number) { 15 System.out.println("Special -digit number"); 16 } else { 17 System.out.println("Not a Special -digit number"); 18 } 19 } 0 } Sample Outputs 1 Enter number: 59 Special -digit number 1 Enter number: 34 Not a Special -digit number Question 6. Write a program to assign a full path and file name as given below. Using library functions, extract and output the file path, file name and file extension separately as shown. Input C:\Users\admin\Pictures\flower.jpg Output Path: C:\Users\admin\Pictures\ File name: flower Extension: jpg We need to use the methods of the String class like indexof(), lastindexof() and substring() to solve this problem. The input String can be divided into three parts, the path, file name and extension. These three parts are separated by a backslash character and a dot as shown in the figure below.

7 7 of :1 So, first we need to find the indices of the backslash character and dot which separate these regions. Note that there are several backslash characters in the input but the backslash character which separates the file path from the name is the last backslash character in the String. So, we need to use the lastindexof() method to find the index of this backslash character. Even though in the example input, there is only one dot, folder names and file names can contain multiple dots. So, for finding the index of the dot which separates the file name and extension also, we use lastindexof() method. Moreover, the backslash character is written as \\ and not \ as \ is an escape character. 1 int indexoflastbackslash = input.lastindexof('\\'); int indexofdot = input.lastindexof('.'); Once, we have the indices of the backslash character and dot, we can use the substring method to extract the three parts. Substring() method takes two integer arguments begin and end; and returns the substring formed by the characters between begin (inclusive) and end (exclusive). 1 String outputpath = input.substring(0, indexoflastbackslash + 1); String filename = input.substring(indexoflastbackslash + 1, indexofdot); 3 String extension = input.substring(indexofdot + 1); Program 1 import java.util.scanner; 3 public class FileName { 4 5 public static void main(string[] args) { 6 Scanner scanner = new Scanner(System.in); 7 System.out.print("Enter file name and path: "); 8 String input = scanner.nextline(); 9 int indexoflastbackslash = input.lastindexof('\\'); 10 int indexofdot = input.lastindexof('.'); 11 String outputpath = input.substring(0, indexoflastbackslash + 1); 1 String filename = input.substring(indexoflastbackslash + 1, indexofdot); 13 String extension = input.substring(indexofdot + 1); 14 System.out.println("Path: " + outputpath); 15 System.out.println("File Name: " + filename); 16 System.out.println("Extension: " + extension); 17 } 18 } Sample Output 1 Enter file name and path: C:\Users\admin\Pictures\flower.jpg Path: C:\Users\admin\Pictures\ 3 File Name: flower 4 Extension: jpg Question 7. Design a class to overload a function area() as follows: (i) double area(double a. double b, double e) with three double arguments, returns the area of a scalene triangle using the formula: where (ii) double area(int a, int b, int height) with three integer arguments, returns the area of a trapezium using the formula: (iii) double area(double diagonal1, double diagonal) with two double arguments, returns the area of a rhombus using the formula: 1 public class Area { 3 public double area(double a, double b, double c) { 4 double s = (a + b + c) / ; 5 double area = Math.sqrt(s * (s - a) * (s - b) * (s - c)); 6 return area; 7 } 8

8 8 of :1 9 public double area(int a, int b, int height) { 10 double area = 0.5 * height * (a + b); 11 return area; 1 } public double area(double diagonal1, double diagonal) { 15 double area = 0.5 * (diagonal1 * diagonal); 16 return area; 17 } 18 } Question 8. Using the switch statement. write a menu driven program to calculate the maturity amount of a Bank Deposit. The user is given the following options: (i) Term Deposit (ii) Recurring Deposit For option (i) accept principal(p), rare of interest(r) and time period in years(n). Calculate and output the maturity amount(a) receivable using the formula For option (ii) accept Monthly Installment (P), rate of interest(r) and time period in months (n). Calculate and output the maturity amount(a) receivable using the formula For an incorrect option, an appropriate error message should be displayed. 1 import java.util.scanner; 3 public class Interest { 4 5 public static void main(string[] args) { 6 Scanner scanner = new Scanner(System.in); 7 System.out.println("Menu"); 8 System.out.println("1. Term Deposit"); 9 System.out.println(". Recurring Deposit"); 10 System.out.print("Enter your choice: "); 11 int choice = scanner.nextint(); 1 switch (choice) { 13 case 1: 14 System.out.print("Enter principal: "); 15 int P1 = scanner.nextint(); 16 System.out.print("Enter rate of interest: "); 17 int r1 = scanner.nextint(); 18 System.out.print("Enter period in years: "); 19 int n1 = scanner.nextint(); 0 double maturityamount1 = P1 * Math.pow(1 + r1 / 100.0, n1); 1 System.out.println("Maturity Amount is " + maturityamount1); break; 3 case : 4 System.out.print("Enter monthly installment: "); 5 int P = scanner.nextint(); 6 System.out.print("Enter rate of interest: "); 7 int r = scanner.nextint(); 8 System.out.print("Enter period in months: "); 9 int n = scanner.nextint(); 30 double maturityamount = P * n + P * (n * (n + 1) /.0) * (r / 100.0) * (1.0 / 1); 31 System.out.println("Maturity Amount is " + maturityamount); 3 break; 33 default: 34 System.out.println("Invalid choice"); 35 } 36 } 37 } Sample Outputs 1 Menu 1. Term Deposit 3. Recurring Deposit 4 Enter your choice: 1 5 Enter principal: Enter rate of interest: 3 7 Enter period in years: 5 8 Maturity Amount is Menu 1. Term Deposit 3. Recurring Deposit

9 9 of :1 4 Enter your choice: 5 Enter monthly installment: Enter rate of interest: 1 7 Enter period in months: 4 8 Maturity Amount is Menu 1. Term Deposit 3. Recurring Deposit 4 Enter your choice: 3 5 Invalid choice Question 9. Write a program to accept the year of graduation from school as an integer value from the user. Using the Binary Search technique on the sorted array of integers given below, output the message Record exists if the value input is located in the array. If not, output the message Record does not exist. (198, 1987, , 1999, 003, 006, 007, 009, 010) 1 import java.util.scanner; 3 public class Search { 4 5 public static void main(string[] args) { 6 Scanner scanner = new Scanner(System.in); 7 System.out.print("Enter year of graduation: "); 8 int graduationyear = scanner.nextint(); 9 int[] years = {198, 1987, 1993, 1996, 1999, 003, 006, 007, 009, 010}; 10 boolean found = false; 11 int left = 0; 1 int right = years.length - 1; 13 while (left <= right) { 14 int middle = (left + right) / ; 15 if (years[middle] == graduationyear) { 16 found = true; 17 break; 18 } else if (years[middle] < graduationyear) { 19 left = middle + 1; 0 } else { 1 right = middle - 1; } 3 } 4 if (found) { 5 System.out.println("Record exists"); 6 } else { 7 System.out.println("Record does not exist"); 8 } 9 } 30 } Sample Outputs 1 Enter year of graduation: 007 Record exists 1 Enter year of graduation: 1900 Record does not exist One thought on ICSE Class 10 Computer Applications ( Java ) 014 Solved Question Paper ajay March 7, 015 at 11:1 am how to calculate RATE OF INTEREST of recurring deposit. Suppose I m investing 500 per month in recurring deposit account for years with rate of interest 8% compounded quarterly. Now I have to find out MATURITY AMOUNT. For this i will use formula : ACTUAL AMOUNT (MATURITY AMOUNT) = PRINCIPLE AMOUNT *( (1+RATE/100/4)^(4*)-1)/(1-(1+RATE/100/4)^(-1/3)) ACTUAL AMOUNT (MATURITY AMOUNT) = PRINCIPLE AMOUNT *( (1+8/100/4)^(4*)-1)/(1-(1+8/100/4)^(-1/3))

10 10 of :1 ACTUAL AMOUNT (MATURITY AMOUNT) = 659/- ======================== Now I want to know the FORMULA OF HOW TO CALCULATE RATE OF INTEREST. Suppose I m investing 500 per month in recurring deposit account interest compounded quarterly. My MATURITY AMOUNT IS 659/-. But i don t know what INTEREST RATE I HAVE GOT. I want to find out INTEREST RATE. WHAT FORMULA SHOULD I USE TO FIND OUT RATE OF INTEREST PLEASE REPLY. (C) ICSE Java, All Rights Reserved

COMPUTER APPLICATIONS

COMPUTER APPLICATIONS COMPUTER APPLICATIONS (Theory) (Two hours) Answers to this Paper must be written on the paper provided separately. You will not be allowed to write during the first 15 minutes. This time is to be spent

More information

COMPUTER APPLICATIONS

COMPUTER APPLICATIONS STATISTICS AT A GLANCE COMPUTER APPLICATIONS Total Number of students who took the examination 89,447 Highest Marks Obtained 100 Lowest Marks Obtained 18 Mean Marks Obtained 83.82 Percentage of Candidates

More information

Using Java Classes Fall 2018 Margaret Reid-Miller

Using Java Classes Fall 2018 Margaret Reid-Miller Using Java Classes 15-121 Fall 2018 Margaret Reid-Miller Today Strings I/O (using Scanner) Loops, Conditionals, Scope Math Class (random) Fall 2018 15-121 (Reid-Miller) 2 The Math Class The Math class

More information

Introduction to Computer Science Unit 2. Notes

Introduction to Computer Science Unit 2. Notes Introduction to Computer Science Unit 2. Notes Name: Objectives: By the completion of this packet, students should be able to describe the difference between.java and.class files and the JVM. create and

More information

Java Foundations: Introduction to Program Design & Data Structures, 4e John Lewis, Peter DePasquale, Joseph Chase Test Bank: Chapter 2

Java Foundations: Introduction to Program Design & Data Structures, 4e John Lewis, Peter DePasquale, Joseph Chase Test Bank: Chapter 2 Java Foundations Introduction to Program Design and Data Structures 4th Edition Lewis TEST BANK Full download at : https://testbankreal.com/download/java-foundations-introduction-toprogram-design-and-data-structures-4th-edition-lewis-test-bank/

More information

ICSE Class 10 Computer Applications ( Java ) 2010 Solved Question...

ICSE Class 10 Computer Applications ( Java ) 2010 Solved Question... 1 of 12 05-11-2015 16:23 ICSE J Java for Class X Computer Applications ICSE Class 10 Computer Applications ( Java ) 2010 Solved Question Paper COMPUTER APPLICATIONS (Theory) Two Hours Answers to this Paper

More information

Introduction to Computer Science Unit 2. Notes

Introduction to Computer Science Unit 2. Notes Introduction to Computer Science Unit 2. Notes Name: Objectives: By the completion of this packet, students should be able to describe the difference between.java and.class files and the JVM. create and

More information

COMPUTER APPLICATIONS

COMPUTER APPLICATIONS COMPUTER APPLICATIONS (Theory) (Two hours) Answers to this Paper must be written on the paper provided separately. You will not be allowed to write during the first 15 minutes. This time is to be spent

More information

Review Chapters 1 to 4. Instructor: Scott Kristjanson CMPT 125/125 SFU Burnaby, Fall 2013

Review Chapters 1 to 4. Instructor: Scott Kristjanson CMPT 125/125 SFU Burnaby, Fall 2013 Review Chapters 1 to 4 Instructor: Scott Kristjanson CMPT 125/125 SFU Burnaby, Fall 2013 Introduction to Java Chapters 1 and 2 The Java Language Section 1.1 Data & Expressions Sections 2.1 2.5 Instructor:

More information

Midterm Examination (MTA)

Midterm Examination (MTA) M105: Introduction to Programming with Java Midterm Examination (MTA) Spring 2013 / 2014 Question One: [6 marks] Choose the correct answer and write it on the external answer booklet. 1. Compilers and

More information

Chapter 4: Control Structures I

Chapter 4: Control Structures I Chapter 4: Control Structures I Java Programming: From Problem Analysis to Program Design, Second Edition Chapter Objectives Learn about control structures. Examine relational and logical operators. Explore

More information

AP CS Unit 3: Control Structures Notes

AP CS Unit 3: Control Structures Notes AP CS Unit 3: Control Structures Notes The if and if-else Statements. These statements are called control statements because they control whether a particular block of code is executed or not. Some texts

More information

CS5000: Foundations of Programming. Mingon Kang, PhD Computer Science, Kennesaw State University

CS5000: Foundations of Programming. Mingon Kang, PhD Computer Science, Kennesaw State University CS5000: Foundations of Programming Mingon Kang, PhD Computer Science, Kennesaw State University Mathematical Functions Java provides many useful methods in the Math class for performing common mathematical

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

CSCI 2010 Principles of Computer Science. Data and Expressions 08/09/2013 CSCI

CSCI 2010 Principles of Computer Science. Data and Expressions 08/09/2013 CSCI CSCI 2010 Principles of Computer Science Data and Expressions 08/09/2013 CSCI 2010 1 Data Types, Variables and Expressions in Java We look at the primitive data types, strings and expressions that are

More information

ICSE Class 10 Computer Applications ( Java ) 2012 Solved Question...

ICSE Class 10 Computer Applications ( Java ) 2012 Solved Question... 1 of 1 05-11-015 16: ICSE J Java for Class X Computer Applications ICSE Class 10 Computer Applications ( Java ) 01 Solved Question Paper COMPUTER APPLICATIONS (Theory) (Two Hours) Answers to this Paper

More information

Chapter 4 Mathematical Functions, Characters, and Strings

Chapter 4 Mathematical Functions, Characters, and Strings Chapter 4 Mathematical Functions, Characters, and Strings Liang, Introduction to Java Programming, Tenth Edition, Global Edition. Pearson Education Limited 2015 1 Motivations Suppose you need to estimate

More information

Programming with Java

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

Getting started with Java

Getting started with Java Getting started with Java Magic Lines public class MagicLines { public static void main(string[] args) { } } Comments Comments are lines in your code that get ignored during execution. Good for leaving

More information

ICSE Class 10 Computer Applications ( Java ) 2013 Solved Question...

ICSE Class 10 Computer Applications ( Java ) 2013 Solved Question... 1 of 14 05-11-2015 16:22 ICSE J Java for Class X Computer Applications ICSE Class 10 Computer Applications ( Java ) 2013 Solved Question Paper If you have any doubts, ask them in the comments section at

More information

CSC Java Programming, Fall Java Data Types and Control Constructs

CSC Java Programming, Fall Java Data Types and Control Constructs CSC 243 - Java Programming, Fall 2016 Java Data Types and Control Constructs Java Types In general, a type is collection of possible values Main categories of Java types: Primitive/built-in Object/Reference

More information

Key Concept: all programs can be broken down to a combination of one of the six instructions Assignment Statements can create variables to represent

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

Operators and Expressions

Operators and Expressions Operators and Expressions Conversions. Widening and Narrowing Primitive Conversions Widening and Narrowing Reference Conversions Conversions up the type hierarchy are called widening reference conversions

More information

Module 4: Characters, Strings, and Mathematical Functions

Module 4: Characters, Strings, and Mathematical Functions Module 4: Characters, Strings, and Mathematical Functions Objectives To solve mathematics problems by using the methods in the Math class ( 4.2). To represent characters using the char type ( 4.3). To

More information

COE 212 Engineering Programming. Welcome to Exam I Tuesday November 11, 2014

COE 212 Engineering Programming. Welcome to Exam I Tuesday November 11, 2014 1 COE 212 Engineering Programming Welcome to Exam I Tuesday November 11, 2014 Instructors: Dr. Bachir Habib Dr. George Sakr Dr. Joe Tekli Dr. Wissam F. Fawaz Name: Student ID: Instructions: 1. This exam

More information

AP Computer Science A

AP Computer Science A AP Computer Science A 1st Quarter Notes Table of Contents - section links Click on the date or topic below to jump to that section Date : 9/8/2017 Aim : Java Basics Objects and Classes Data types: Primitive

More information

Section 2: Introduction to Java. Historical note

Section 2: Introduction to Java. Historical note The only way to learn a new programming language is by writing programs in it. - B. Kernighan & D. Ritchie Section 2: Introduction to Java Objectives: Data Types Characters and Strings Operators and Precedence

More information

Chapter 2: Data and Expressions

Chapter 2: Data and Expressions Chapter 2: Data and Expressions CS 121 Department of Computer Science College of Engineering Boise State University January 15, 2015 Chapter 2: Data and Expressions CS 121 1 / 1 Chapter 2 Part 1: Data

More information

H212 Introduction to Software Systems Honors

H212 Introduction to Software Systems Honors Introduction to Software Systems Honors Lecture #04: Fall 2015 1/20 Office hours Monday, Wednesday: 10:15 am to 12:00 noon Tuesday, Thursday: 2:00 to 3:45 pm Office: Lindley Hall, Room 401C 2/20 Printing

More information

when you call the method, you do not have to know exactly what those instructions are, or even how the object is organized internally

when you call the method, you do not have to know exactly what those instructions are, or even how the object is organized internally I. Methods week 4 a method consists of a sequence of instructions that can access the internal data of an object (strict method) or to perform a task with input from arguments (static method) when you

More information

Question: Total Points: Score:

Question: Total Points: Score: CS 170 Exam 1 Section 001 Fall 2014 Name (print): Instructions: Keep your eyes on your own paper and do your best to prevent anyone else from seeing your work. Do NOT communicate with anyone other than

More information

Advanced Object Concepts

Advanced Object Concepts Understanding Blocks Blocks - Appears within any class or method, the code between a pair of curly braces Outside block- The first block, begins immediately after the method declaration and ends at the

More information

Full file at

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

Lab5. Wooseok Kim

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

More information

Programming: Java. Chapter Objectives. Control Structures. Chapter 4: Control Structures I. Program Design Including Data Structures

Programming: Java. Chapter Objectives. Control Structures. Chapter 4: Control Structures I. Program Design Including Data Structures Chapter 4: Control Structures I Java Programming: Program Design Including Data Structures Chapter Objectives Learn about control structures Examine relational and logical operators Explore how to form

More information

What did we talk about last time? Examples switch statements

What did we talk about last time? Examples switch statements Week 4 - Friday What did we talk about last time? Examples switch statements History of computers Hardware Software development Basic Java syntax Output with System.out.print() Mechanical Calculation

More information

In this chapter, you will:

In this chapter, you will: Java Programming: Guided Learning with Early Objects Chapter 4 Control Structures I: Selection In this chapter, you will: Make decisions with the if and if else structures Use compound statements in an

More information

Lecture 6. Assignments. Java Scanner. User Input 1/29/18. Reading: 2.12, 2.13, 3.1, 3.2, 3.3, 3.4

Lecture 6. Assignments. Java Scanner. User Input 1/29/18. Reading: 2.12, 2.13, 3.1, 3.2, 3.3, 3.4 Assignments Reading: 2.12, 2.13, 3.1, 3.2, 3.3, 3.4 Lecture 6 Complete for Lab 4, Project 1 Note: Slides 12 19 are summary slides for Chapter 2. They overview much of what we covered but are not complete.

More information

Object Oriented Programming. Java-Lecture 1

Object Oriented Programming. Java-Lecture 1 Object Oriented Programming Java-Lecture 1 Standard output System.out is known as the standard output object Methods to display text onto the standard output System.out.print prints text onto the screen

More information

Chapter 2: Data and Expressions

Chapter 2: Data and Expressions Chapter 2: Data and Expressions CS 121 Department of Computer Science College of Engineering Boise State University April 21, 2015 Chapter 2: Data and Expressions CS 121 1 / 53 Chapter 2 Part 1: Data Types

More information

Data and Expressions. Outline. Data and Expressions 12/18/2010. Let's explore some other fundamental programming concepts. Chapter 2 focuses on:

Data and Expressions. Outline. Data and Expressions 12/18/2010. Let's explore some other fundamental programming concepts. Chapter 2 focuses on: Data and Expressions Data and Expressions Let's explore some other fundamental programming concepts Chapter 2 focuses on: Character Strings Primitive Data The Declaration And Use Of Variables Expressions

More information

JAVA OPERATORS GENERAL

JAVA OPERATORS GENERAL JAVA OPERATORS GENERAL Java provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following groups: Arithmetic Operators Relational Operators Bitwise Operators

More information

The Math Class. Using various math class methods. Formatting the values.

The Math Class. Using various math class methods. Formatting the values. The Math Class Using various math class methods. Formatting the values. The Math class is used for mathematical operations; in our case some of its functions will be used. In order to use the Math class,

More information

CONTENTS: Compilation Data and Expressions COMP 202. More on Chapter 2

CONTENTS: Compilation Data and Expressions COMP 202. More on Chapter 2 CONTENTS: Compilation Data and Expressions COMP 202 More on Chapter 2 Programming Language Levels There are many programming language levels: machine language assembly language high-level language Java,

More information

Jump Statements. The keyword break and continue are often used in repetition structures to provide additional controls.

Jump Statements. The keyword break and continue are often used in repetition structures to provide additional controls. Jump Statements The keyword break and continue are often used in repetition structures to provide additional controls. break: the loop is terminated right after a break statement is executed. continue:

More information

CSE 1223: Introduction to Computer Programming in Java Chapter 2 Java Fundamentals

CSE 1223: Introduction to Computer Programming in Java Chapter 2 Java Fundamentals CSE 1223: Introduction to Computer Programming in Java Chapter 2 Java Fundamentals 1 Recall From Last Time: Java Program import java.util.scanner; public class EggBasketEnhanced { public static void main(string[]

More information

MIDTERM REVIEW. midterminformation.htm

MIDTERM REVIEW.   midterminformation.htm MIDTERM REVIEW http://pages.cpsc.ucalgary.ca/~tamj/233/exams/ midterminformation.htm 1 REMINDER Midterm Time: 7:00pm - 8:15pm on Friday, Mar 1, 2013 Location: ST 148 Cover everything up to the last lecture

More information

A variable is a name for a location in memory A variable must be declared

A variable is a name for a location in memory A variable must be declared Variables A variable is a name for a location in memory A variable must be declared, specifying the variable's name and the type of information that will be held in it data type variable name int total;

More information

Mathematical Functions, Characters, and Strings. CSE 114, Computer Science 1 Stony Brook University

Mathematical Functions, Characters, and Strings. CSE 114, Computer Science 1 Stony Brook University Mathematical Functions, Characters, and Strings CSE 114, Computer Science 1 Stony Brook University http://www.cs.stonybrook.edu/~cse114 1 Static methods Remember the main method header? public static void

More information

Example: Monte Carlo Simulation 1

Example: Monte Carlo Simulation 1 Example: Monte Carlo Simulation 1 Write a program which conducts a Monte Carlo simulation to estimate π. 1 See https://en.wikipedia.org/wiki/monte_carlo_method. Zheng-Liang Lu Java Programming 133 / 149

More information

Topics. Chapter 5. Equality Operators

Topics. Chapter 5. Equality Operators Topics Chapter 5 Flow of Control Part 1: Selection Forming Conditions if/ Statements Comparing Floating-Point Numbers Comparing Objects The equals Method String Comparison Methods The Conditional Operator

More information

Lecture 6. Assignments. Summary - Variables. Summary Program Parts 1/29/18. Reading: 3.1, 3.2, 3.3, 3.4

Lecture 6. Assignments. Summary - Variables. Summary Program Parts 1/29/18. Reading: 3.1, 3.2, 3.3, 3.4 Assignments Lecture 6 Complete for Project 1 Reading: 3.1, 3.2, 3.3, 3.4 Summary Program Parts Summary - Variables Class Header (class name matches the file name prefix) Class Body Because this is a program,

More information

Java Tutorial. Saarland University. Ashkan Taslimi. Tutorial 3 September 6, 2011

Java Tutorial. Saarland University. Ashkan Taslimi. Tutorial 3 September 6, 2011 Java Tutorial Ashkan Taslimi Saarland University Tutorial 3 September 6, 2011 1 Outline Tutorial 2 Review Access Level Modifiers Methods Selection Statements 2 Review Programming Style and Documentation

More information

AP Computer Science Unit 1. Writing Programs Using BlueJ

AP Computer Science Unit 1. Writing Programs Using BlueJ AP Computer Science Unit 1. Writing Programs Using BlueJ 1. Open up BlueJ. Click on the Project menu and select New Project. You should see the window on the right. Navigate to wherever you plan to save

More information

COMP-202B - Introduction to Computing I (Winter 2011) - All Sections Example Questions for In-Class Quiz

COMP-202B - Introduction to Computing I (Winter 2011) - All Sections Example Questions for In-Class Quiz COMP-202B - Introduction to Computing I (Winter 2011) - All Sections Example Questions for In-Class Quiz The in-class quiz is intended to give you a taste of the midterm, give you some early feedback about

More information

Chapter 3: Operators, Expressions and Type Conversion

Chapter 3: Operators, Expressions and Type Conversion 101 Chapter 3 Operators, Expressions and Type Conversion Chapter 3: Operators, Expressions and Type Conversion Objectives To use basic arithmetic operators. To use increment and decrement operators. To

More information

M105: Introduction to Programming with Java Midterm Examination (MTA) Makeup Spring 2013 / 2014

M105: Introduction to Programming with Java Midterm Examination (MTA) Makeup Spring 2013 / 2014 M105: Introduction to Programming with Java Midterm Examination (MTA) Makeup Spring 2013 / 2014 Question One: Choose the correct answer and write it on the external answer booklet. 1. Java is. a. case

More information

Pace University. Fundamental Concepts of CS121 1

Pace University. Fundamental Concepts of CS121 1 Pace University Fundamental Concepts of CS121 1 Dr. Lixin Tao http://csis.pace.edu/~lixin Computer Science Department Pace University October 12, 2005 This document complements my tutorial Introduction

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

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

Mathematical Functions, Characters, and Strings. CSE 114, Computer Science 1 Stony Brook University

Mathematical Functions, Characters, and Strings. CSE 114, Computer Science 1 Stony Brook University Mathematical Functions, Characters, and Strings CSE 114, Computer Science 1 Stony Brook University http://www.cs.stonybrook.edu/~cse114 1 Static methods Remember the main method header? public static void

More information

Oct Decision Structures cont d

Oct Decision Structures cont d Oct. 29 - Decision Structures cont d Programming Style and the if Statement Even though an if statement usually spans more than one line, it is really one statement. For instance, the following if statements

More information

Eng. Mohammed S. Abdualal

Eng. Mohammed S. Abdualal Islamic University of Gaza Faculty of Engineering Computer Engineering Dept. Computer Programming Lab (ECOM 2114) Created by Eng: Mohammed Alokshiya Modified by Eng: Mohammed Abdualal Lab 3 Selections

More information

Outline. Parts 1 to 3 introduce and sketch out the ideas of OOP. Part 5 deals with these ideas in closer detail.

Outline. Parts 1 to 3 introduce and sketch out the ideas of OOP. Part 5 deals with these ideas in closer detail. OOP in Java 1 Outline 1. Getting started, primitive data types and control structures 2. Classes and objects 3. Extending classes 4. Using some standard packages 5. OOP revisited Parts 1 to 3 introduce

More information

CSC 1051 Algorithms and Data Structures I. Midterm Examination February 25, Name: KEY A

CSC 1051 Algorithms and Data Structures I. Midterm Examination February 25, Name: KEY A CSC 1051 Algorithms and Data Structures I Midterm Examination February 25, 2016 Name: KEY A Question Value Score 1 10 2 10 3 10 4 10 5 10 6 10 7 10 8 10 9 10 10 10 TOTAL 100 Please answer questions in

More information

4. Java Project Design, Input Methods

4. Java Project Design, Input Methods 4-1 4. Java Project Design, Input Methods Review and Preview You should now be fairly comfortable with creating, compiling and running simple Java projects. In this class, we continue learning new Java

More information

COMPUTER APPLICATIONS

COMPUTER APPLICATIONS COMPUTER APPLICATIONS (Theory) (Two Hours) Answers to this Paper must be written on the paper provided separately. You will not be allowed to write during the first 15 minutes. This time is to be spent

More information

CSC Algorithms and Data Structures I. Midterm Examination February 25, Name:

CSC Algorithms and Data Structures I. Midterm Examination February 25, Name: CSC 1051-001 Algorithms and Data Structures I Midterm Examination February 25, 2016 Name: Question Value Score 1 10 2 10 3 10 4 10 5 10 6 10 7 10 8 10 9 10 10 10 TOTAL 100 Please answer questions in the

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

Selec%on and Decision Structures in Java: If Statements and Switch Statements CSC 121 Fall 2016 Howard Rosenthal

Selec%on and Decision Structures in Java: If Statements and Switch Statements CSC 121 Fall 2016 Howard Rosenthal Selec%on and Decision Structures in Java: If Statements and Switch Statements CSC 121 Fall 2016 Howard Rosenthal Lesson Goals Understand Control Structures Understand how to control the flow of a program

More information

COMP 202. Built in Libraries and objects. CONTENTS: Introduction to objects Introduction to some basic Java libraries string

COMP 202. Built in Libraries and objects. CONTENTS: Introduction to objects Introduction to some basic Java libraries string COMP 202 Built in Libraries and objects CONTENTS: Introduction to objects Introduction to some basic Java libraries string COMP 202 Objects and Built in Libraries 1 Classes and Objects An object is an

More information

Jump Statements. The keyword break and continue are often used in repetition structures to provide additional controls.

Jump Statements. The keyword break and continue are often used in repetition structures to provide additional controls. Jump Statements The keyword break and continue are often used in repetition structures to provide additional controls. break: the loop is terminated right after a break statement is executed. continue:

More information

Java Basic Programming Constructs

Java Basic Programming Constructs Java Basic Programming Constructs /* * This is your first java program. */ class HelloWorld{ public static void main(string[] args){ System.out.println( Hello World! ); A Closer Look at HelloWorld 2 This

More information

Section 004 Spring CS 170 Exam 1. Name (print): Instructions:

Section 004 Spring CS 170 Exam 1. Name (print): Instructions: CS 170 Exam 1 Section 004 Spring 2014 Name (print): Instructions: Keep your eyes on your own paper and do your best to prevent anyone else from seeing your work. Do NOT communicate with anyone other than

More information

Interpreted vs Compiled. Java Compile. Classes, Objects, and Methods. Hello World 10/6/2016. Python Interpreted. Java Compiled

Interpreted vs Compiled. Java Compile. Classes, Objects, and Methods. Hello World 10/6/2016. Python Interpreted. Java Compiled Interpreted vs Compiled Python 1 Java Interpreted Easy to run and test Quicker prototyping Program runs slower Compiled Execution time faster Virtual Machine compiled code portable Java Compile > javac

More information

double float char In a method: final typename variablename = expression ;

double float char In a method: final typename variablename = expression ; Chapter 4 Fundamental Data Types The Plan For Today Return Chapter 3 Assignment/Exam Corrections Chapter 4 4.4: Arithmetic Operations and Mathematical Functions 4.5: Calling Static Methods 4.6: Strings

More information

boolean, char, class, const, double, else, final, float, for, if, import, int, long, new, public, return, static, throws, void, while

boolean, char, class, const, double, else, final, float, for, if, import, int, long, new, public, return, static, throws, void, while CSCI 150 Fall 2007 Java Syntax The following notes are meant to be a quick cheat sheet for Java. It is not meant to be a means on its own to learn Java or this course. For that you should look at your

More information

Computer Programming, I. Laboratory Manual. Experiment #4. Mathematical Functions & Characters

Computer Programming, I. Laboratory Manual. Experiment #4. Mathematical Functions & Characters 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 #4

More information

Tester vs. Controller. Elementary Programming. Learning Outcomes. Compile Time vs. Run Time

Tester vs. Controller. Elementary Programming. Learning Outcomes. Compile Time vs. Run Time Tester vs. Controller Elementary Programming EECS1022: Programming for Mobile Computing Winter 2018 CHEN-WEI WANG For effective illustrations, code examples will mostly be written in the form of a tester

More information

Example. Write a program which sums two random integers and lets the user repeatedly enter a new answer until it is correct.

Example. Write a program which sums two random integers and lets the user repeatedly enter a new answer until it is correct. Example Write a program which sums two random integers and lets the user repeatedly enter a new answer until it is correct. 1... 2 Scanner input = new Scanner(System.in); 3 int x = (int) (Math.random()

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

COMP-202 Unit 4: Programming With Iterations. CONTENTS: The while and for statements

COMP-202 Unit 4: Programming With Iterations. CONTENTS: The while and for statements COMP-202 Unit 4: Programming With Iterations CONTENTS: The while and for statements Introduction (1) Suppose we want to write a program to be used in cash registers in stores to compute the amount of money

More information

Chapter 3. Selections

Chapter 3. Selections Chapter 3 Selections 1 Outline 1. Flow of Control 2. Conditional Statements 3. The if Statement 4. The if-else Statement 5. The Conditional operator 6. The Switch Statement 7. Useful Hints 2 1. Flow of

More information

Important Java terminology

Important Java terminology 1 Important Java terminology The information we manage in a Java program is either represented as primitive data or as objects. Primitive data פרימיטיביים) (נתונים include common, fundamental values as

More information

Last Class. While loops Infinite loops Loop counters Iterations

Last Class. While loops Infinite loops Loop counters Iterations Last Class While loops Infinite loops Loop counters Iterations public class January31{ public static void main(string[] args) { while (true) { forloops(); if (checkclassunderstands() ) { break; } teacharrays();

More information

Elementary Programming

Elementary Programming Elementary Programming EECS1022: Programming for Mobile Computing Winter 2018 CHEN-WEI WANG Learning Outcomes Learn ingredients of elementary programming: data types [numbers, characters, strings] literal

More information

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

Entry Point of Execution: the main Method. Elementary Programming. Learning Outcomes. Development Process Entry Point of Execution: the main Method Elementary Programming EECS1021: Object Oriented Programming: from Sensors to Actuators Winter 2019 CHEN-WEI WANG For now, all your programming exercises will

More information

CSC 1214: Object-Oriented Programming

CSC 1214: Object-Oriented Programming CSC 1214: Object-Oriented Programming J. Kizito Makerere University e-mail: jkizito@cis.mak.ac.ug www: http://serval.ug/~jona materials: http://serval.ug/~jona/materials/csc1214 e-learning environment:

More information

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

Assoc. Prof. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved. Assoc. Prof. Marenglen Biba (C) 2010 Pearson Education, Inc. All This chapter discusses class String, from the java.lang package. These classes provide the foundation for string and character manipulation

More information

Chapter 2 ELEMENTARY PROGRAMMING

Chapter 2 ELEMENTARY PROGRAMMING Chapter 2 ELEMENTARY PROGRAMMING Lecture notes for computer programming 1 Faculty of Engineering and Information Technology Prepared by: Iyad Albayouk ١ Objectives To write Java programs to perform simple

More information

COMP-202: Foundations of Programming. Lecture 3: Boolean, Mathematical Expressions, and Flow Control Sandeep Manjanna, Summer 2015

COMP-202: Foundations of Programming. Lecture 3: Boolean, Mathematical Expressions, and Flow Control Sandeep Manjanna, Summer 2015 COMP-202: Foundations of Programming Lecture 3: Boolean, Mathematical Expressions, and Flow Control Sandeep Manjanna, Summer 2015 Announcements Slides will be posted before the class. There might be few

More information

To define methods, invoke methods, and pass arguments to a method ( ). To develop reusable code that is modular, easy-toread, easy-to-debug,

To define methods, invoke methods, and pass arguments to a method ( ). To develop reusable code that is modular, easy-toread, easy-to-debug, 1 To define methods, invoke methods, and pass arguments to a method ( 5.2-5.5). To develop reusable code that is modular, easy-toread, easy-to-debug, and easy-to-maintain. ( 5.6). To use method overloading

More information

Object oriented programming. Instructor: Masoud Asghari Web page: Ch: 3

Object oriented programming. Instructor: Masoud Asghari Web page:   Ch: 3 Object oriented programming Instructor: Masoud Asghari Web page: http://www.masses.ir/lectures/oops2017sut Ch: 3 1 In this slide We follow: https://docs.oracle.com/javase/tutorial/index.html Trail: Learning

More information

Basic Operations jgrasp debugger Writing Programs & Checkstyle

Basic Operations jgrasp debugger Writing Programs & Checkstyle Basic Operations jgrasp debugger Writing Programs & Checkstyle Suppose you wanted to write a computer game to play "Rock, Paper, Scissors". How many combinations are there? Is there a tricky way to represent

More information

COMP 202 Java in one week

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

Date: Dr. Essam Halim

Date: Dr. Essam Halim Assignment (1) Date: 11-2-2013 Dr. Essam Halim Part 1: Chapter 2 Elementary Programming 1 Suppose a Scanner object is created as follows: Scanner input = new Scanner(System.in); What method do you use

More information

CS111: PROGRAMMING LANGUAGE II

CS111: 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 information

Selec%on and Decision Structures in Java: If Statements and Switch Statements CSC 121 Spring 2016 Howard Rosenthal

Selec%on and Decision Structures in Java: If Statements and Switch Statements CSC 121 Spring 2016 Howard Rosenthal Selec%on and Decision Structures in Java: If Statements and Switch Statements CSC 121 Spring 2016 Howard Rosenthal Lesson Goals Understand Control Structures Understand how to control the flow of a program

More information

Basic Programming Elements

Basic Programming Elements Chapter 2 Basic Programming Elements Lecture slides for: Java Actually: A Comprehensive Primer in Programming Khalid Azim Mughal, Torill Hamre, Rolf W. Rasmussen Cengage Learning, 2008. ISBN: 978-1-844480-933-2

More information

Operators. Java operators are classified into three categories:

Operators. Java operators are classified into three categories: Operators Operators are symbols that perform arithmetic and logical operations on operands and provide a meaningful result. Operands are data values (variables or constants) which are involved in operations.

More information