Respostas dos Exercícios de Programação Java

Size: px
Start display at page:

Download "Respostas dos Exercícios de Programação Java"

Transcription

1 Exercício 3. 3a) package exercicio.pkg3a; Respostas s Exercícios de Programação Java public class Exercicio3a int tab, i=1; System.out.print("Digite a tabuada: "); tab = leia.nextint(); System.out.println("\nTabuada de " + tab); while(i <= 10) System.out.println(tab + " x " + i + " = " + (tab*i)); i++; 3b) package exercicio.pkg3b; public class Exercicio3b int soma=0, i=1; while(i <= 100) soma += i; i++; System.out.println("A soma s valores de 1 até 100 é: " + soma); 3c) package exercicio.pkg3c; public class Exercicio3c int soma=0, i=2; while(i <= 500) soma += i; i += 2; System.out.println("A soma s valores pares de 1 até 500 é: " + soma);

2 3d) package exercicio.pkg3d; public class Exercicio3d int i=0; while(i <= 20) if (i % 2 == 1) System.out.println(i); i++; 3e) package exercicio.pkg3e; public class Exercicio3e int pot, exp=0, i; while(exp <= 15) pot = 1; i = 0; while(exp > 0 && i < exp) pot *= 3; i++; System.out.println("3 ^ " + exp + " = " + pot); exp++;

3 3f) package exercicio.pkg3f; public class Exercicio3f int exp, pot = 1, i = 0; float base; System.out.print("Digite a base da potência: "); base = leia.nextfloat(); System.out.print("Digite o expoente inteiro da potência: "); exp = leia.nextint(); while(exp > 0 && i < exp) pot *= base; i++; System.out.println(base + " ^ " + exp + " = " + pot); 3g) package exercicio.pkg3g; public class Exercicio3g int a = 1, b = 1, prox, i = 3; System.out.print("1, 1"); while( i <= 15) prox = a + b; a = b; b = prox; System.out.print(", " + prox); i++; 3h) package exercicio.pkg3h; public class Exercicio3h int C = 10; float F; while(c <= 100) F = (9*C + 160)/5; System.out.println(C + "ºC = " + F + "ºF"); C += 10;

4 3i) package exercicio.pkg3i; public class Exercicio3i int i = 1; float num, soma = 0; while(i <= 10) System.out.print("Digite o " + i + "º número: "); num = leia.nextfloat(); soma += num; i++; System.out.println("Somatório = " + soma); System.out.println("Média = " + soma/10); 3j) package exercicio.pkg3j; public class Exercicio3j int i = 50, soma = 0, qtd = 0; while(i <= 70) soma += i; i+=2; qtd++; System.out.println("Somatório = " + soma); System.out.println("Média = " + soma/qtd);

5 3k) package exercicio.pkg3k; public class Exercicio3k float areac, areat = 0, larg, comp; String resp = "SIM", como; while(!resp.touppercase().equals("nao")) System.out.print("Digite o nome cômo: "); como = leia.nextline(); System.out.print("Digite o comprimento cômo: "); comp = leia.nextfloat(); System.out.print("Digite a largura cômo: "); larg = leia.nextfloat(); areac = comp * larg; System.out.println("A área (a) " + como + " é: " + areac); areat += areac; System.out.print("\nDeseja calcular outro cômo? "); leia.nextline(); resp = leia.nextline(); System.out.println("\nA área total é: " + areat);

6 3l) package exercicio.pkg3l; public class Exercicio3l int valor=0, maior = 0, menor = 0; boolean primeiro = true; while(valor >=0 ) System.out.print("Digite um valor (se negativo finaliza): "); valor = leia.nextint(); if (primeiro) maior = valor; menor = valor; primeiro = false; if(valor >=0) if(valor > maior) maior = valor; if(valor < menor) menor = valor; System.out.println("O maior valor é: " + maior); System.out.println("O menor valor é: " + menor);

7 Exercício 4. 4a) package exercicio.pkg4a; public class Exercicio4a int n = 15; System.out.println("Quadra de " + n + " = " + (n*n)); n++; while(n <= 200); 4b) package exercicio.pkg4b; public class Exercicio4b int n = 1, soma = 0; soma += n; n+=2; while(n <= 500); System.out.println("A soma s valores ímpares de 1 à 500 é: " + soma); 4c) package exercicio.pkg4c; public class Exercicio4c int i=1; if (i % 4 == 0) System.out.println(i); i++; while(i < 200);

8 4d) package exercicio.pkg4d; public class Exercicio4d int i = 2; float qtd = 1, total = 1; qtd *= 2; total += qtd; i++; while(i <= 64); System.out.println("O total de grãos tabuleiro é: " + total); 4e) package exercicio.pkg4e; public class Exercicio4e int valor, n = 1; float fat, total = 0; System.out.print("Entre com o " + n + "º número: "); valor = leia.nextint(); fat = 1; System.out.print("O fatorial de " + valor + " é: "); if(valor == 0) fat = 1; else fat *= valor; valor--; while(valor > 0); System.out.println(fat); total += fat; n++; while(n <= 15); System.out.println("A soma s fatoriais é: " + total);

9 4f) package exercicio.pkg4f; public class Exercicio4f int qtd = 0; float valor, soma = 0; System.out.print("Entre com o " + (qtd+1) + "º número: "); valor = leia.nextint(); if(valor >= 0) soma += valor; qtd++; while(valor >= 0); if(qtd > 0) System.out.println("A soma s valores é: " + soma); System.out.println("A média s valores é: " + soma/qtd); System.out.println("A quantidade de valores é: " + qtd); else System.out.println("Não existem valores para calcular!!!!");

10 4g) package exercicio.pkg4g; public class Exercicio4g int valor = 1, n = 1; float fat; fat = 1; if(valor == 0) fat = 1; else n = valor; fat *= n; n--; while(n > 0); System.out.println("O fatorial de " + valor + " é: " + fat); valor += 2; while(valor <= 10);

11 4h) package exercicio.pkg4h; public class Exercicio4h float areac, areat = 0, larg, comp; String resp, como; System.out.print("Digite o nome cômo: "); como = leia.nextline(); System.out.print("Digite o comprimento cômo: "); comp = leia.nextfloat(); System.out.print("Digite a largura cômo: "); larg = leia.nextfloat(); areac = comp * larg; System.out.println("A área (a) " + como + " é: " + areac); areat += areac; System.out.print("\nDeseja calcular outro cômo? "); leia.nextline(); resp = leia.nextline(); while(!resp.touppercase().equals("nao")); System.out.println("\nA área total é: " + areat);

12 4i) package exercicio.pkg4i; public class Exercicio4i int valor=0, maior = 0, menor = 0; boolean primeiro = true; System.out.print("Digite um valor (se negativo finaliza): "); valor = leia.nextint(); if (primeiro) maior = valor; menor = valor; primeiro = false; if(valor >=0) if(valor > maior) maior = valor; if(valor < menor) menor = valor; while(valor >=0 ); if(maior < 0 menor < 0) System.out.println("Não existem valores para calcular a média!!!!"); else System.out.println("O maior valor é: " + maior); System.out.println("O menor valor é: " + menor); System.out.println("O média é: " + ((maior+menor)/2));

13 4j) package exercicio.pkg4j; public class Exercicio4j int divisor, dividen, res, qtd = 0; System.out.print("Digite um valor inteiro a ser dividi: "); dividen = leia.nextint(); System.out.print("Digite um valor inteiro como divisor: "); divisor = leia.nextint(); res = dividen; if(divisor <= dividen) res -= divisor; qtd++; while(res >= divisor); System.out.println("O resulta da divisão é: " + qtd);

14 Exercício 5. 5a) package exercicio.pkg5a; public class Exercicio5a int n; for(n = 15; n <= 200; n++) System.out.println("O cubo de " + n + " = " + (n*n*n)); 5b) package exercicio.pkg5b; public class Exercicio5b int tab, i; System.out.print("Digite a tabuada: "); tab = leia.nextint(); System.out.println("\nTabuada de " + tab); for(i = 1; i <= 10; i++) System.out.println(tab + " x " + i + " = " + (tab*i)); 5c) package exercicio.pkg5c; public class Exercicio5c int soma=0, i; for(i = 1; i <= 100; i++) soma += i; System.out.println("A soma s valores de 1 até 100 é: " + soma);

15 5d) package exercicio.pkg5d; public class Exercicio5d int soma=0, i=2; for(i = 7; i <= 500; i += 7) soma += i; System.out.println("A soma s múltiplos de 7 de 1 até 500 é: " + soma); 5e) package exercicio.pkg5e; public class Exercicio5e int i; for(i = 0; i <= 20; i++) if (i % 2 == 1) System.out.println(i); 5f) package exercicio.pkg5f; public class Exercicio5f int i; for(i = 0; i <= 200; i++) if (i % 4 == 0) System.out.println(i);

16 5g) package exercicio.pkg5g; public class Exercicio5g int pot = 1, exp, i; for(exp = 0; exp <= 15; exp++) pot = 1; if(exp!= 0) for(i = 1; i <= exp; i++) pot *= 5; System.out.println("5 ^ " + exp + " = " + pot); 5h) package exercicio.pkg5h; public class Exercicio5h int exp, pot = 1, i = 0; float base; System.out.print("Digite a base da potência: "); base = leia.nextfloat(); System.out.print("Digite o expoente inteiro da potência: "); exp = leia.nextint(); if(exp!= 0) for(i = 0; i < exp; i++) pot *= base; System.out.println(base + " ^ " + exp + " = " + pot);

17 5i) package exercicio.pkg5i; public class Exercicio5i int a = 1, b = 1, prox, i; System.out.print("1, 1"); for(i = 3; i <= 15; i++) prox = a + b; a = b; b = prox; System.out.print(", " + prox); 5j) package exercicio.pkg5j; public class Exercicio5j int C; float F; for(c = 10; C <= 100; C += 10) F = (9*C + 160)/5; System.out.println(C + "ºC = " + F + "ºF");

18 5k) package exercicio.pkg5k; public class Exercicio5k int valor = 1, n; float fat; for(valor = 1; valor <= 10; valor += 2) fat = 1; if(valor == 0) fat = 1; else n = valor; fat *= n; n--; while(n > 0); System.out.println("O fatorial de " + valor + " é: " + fat);

19 Exercício 6. 6a) package exercicio.pkg6a; public class Exercicio6a int[] vetor = new int[10]; int i; for(i = 0; i < 10; i++) System.out.print("Digite o " + (i+1) + "º número: "); vetor[i] = leia.nextint(); System.out.println("Apresentan o conteú vetor."); for(i = 0; i < 10; i++) System.out.println("Vetor[" + i + "] = " + vetor[i]); 6b) package exercicio.pkg6b; public class Exercicio6b int[] A = new int[8]; int[] B = new int[8]; int i; for(i = 0; i < 8; i++) System.out.print("Digite o " + (i+1) + "º número: "); A[i] = leia.nextint(); for(i = 0; i < 8; i++) B[i] = A[i]*3; System.out.println("Apresentan o conteú vetor B."); for(i = 0; i < 8; i++) System.out.println("B[" + i + "] = " + B[i]);

20 6c) package exercicio.pkg6c; public class Exercicio6c int[] A = new int[20]; int[] B = new int[20]; int[] C = new int[20]; int i; for(i = 0; i < 20; i++) System.out.print("Digite o " + (i+1) + "º número vetor A: "); A[i] = leia.nextint(); for(i = 0; i < 20; i++) System.out.print("Digite o " + (i+1) + "º número vetor B: "); B[i] = leia.nextint(); for(i = 0; i < 20; i++) C[i] = A[i] - B[i]; System.out.println("Apresentan o conteú vetor C."); for(i = 0; i < 20; i++) System.out.println("C[" + i + "] = " + C[i]);

21 6d) package exercicio.pkg6d; public class Exercicio6d int[] A = new int[15]; int[] B = new int[15]; int i; for(i = 0; i < 15; i++) System.out.print("Digite o " + (i+1) + "º número vetor A: "); A[i] = leia.nextint(); for(i = 0; i < 15; i++) B[i] = A[i]*A[i]; System.out.println("Apresentan o conteú vetor A e veetor B."); for(i = 0; i < 15; i++) System.out.println("A[" + i + "] = " + A[i] + " e B[" + i + "] = " + B[i]);

22 6e) package exercicio.pkg6e; public class Exercicio6e int[] A = new int[15]; int[] B = new int[15]; int[] C = new int[30]; int i; for(i = 0; i < 15; i++) System.out.print("Digite o " + (i+1) + "º número vetor A: "); A[i] = leia.nextint(); for(i = 0; i < 15; i++) System.out.print("Digite o " + (i+1) + "º número vetor B: "); B[i] = leia.nextint(); for(i = 0; i < 15; i++) C[i] = A[i]; C[15+i] = B[i]; System.out.println("Apresentan o conteú vetor C."); for(i = 0; i < 30; i++) System.out.println("C[" + i + "] = " + C[i]);

23 6f) package exercicio.pkg6f; public class Exercicio6f int[] A = new int[20]; int[] B = new int[30]; int[] C = new int[50]; int i; for(i = 0; i < 20; i++) System.out.print("Digite o " + (i+1) + "º número vetor A: "); A[i] = leia.nextint(); for(i = 0; i < 30; i++) System.out.print("Digite o " + (i+1) + "º número vetor B: "); B[i] = leia.nextint(); for(i = 0; i < 20; i++) C[i] = A[i]; for(i = 0; i < 30; i++) C[20+i] = B[i]; System.out.println("Apresentan o conteú vetor C."); for(i = 0; i < 50; i++) System.out.println("C[" + i + "] = " + C[i]);

24 6g) package exercicio.pkg6g; public class Exercicio6g int[] A = new int[20]; int[] B = new int[20]; int i; for(i = 0; i < 20; i++) System.out.print("Digite o " + (i+1) + "º número vetor A: "); A[i] = leia.nextint(); for(i = 0; i < 20; i++) B[i] = A[19-i]; System.out.println("Apresentan o conteú vetor A e veetor B."); for(i = 0; i < 20; i++) System.out.println("A[" + i + "] = " + A[i] + " e B[" + i + "] = " + B[i]);

25 6h) package exercicio.pkg6h; public class Exercicio6h int[] A = new int[5]; int[] B = new int[5]; int[] C = new int[5]; int[] D = new int[15]; int i; for(i = 0; i < 5; i++) System.out.print("Digite o " + (i+1) + "º número vetor A: "); A[i] = leia.nextint(); for(i = 0; i < 5; i++) System.out.print("Digite o " + (i+1) + "º número vetor B: "); B[i] = leia.nextint(); for(i = 0; i < 5; i++) System.out.print("Digite o " + (i+1) + "º número vetor C: "); C[i] = leia.nextint(); for(i = 0; i < 5; i++) D[i] = A[i]; D[5+i] = B[i]; D[10+i] = C[i]; System.out.println("Apresentan o conteú vetor C."); for(i = 0; i < 15; i++) System.out.println("D[" + i + "] = " + D[i]);

26 6i) package exercicio.pkg6i; public class Exercicio6i float[] A = new float[15]; float[] B = new float[15]; int i; for(i = 0; i < 15; i++) System.out.print("Digite o " + (i+1) + "º número vetor A: "); A[i] = leia.nextint(); for(i = 0; i < 15; i++) if(i % 2 == 0) B[i] = A[i]/2; else B[i] = A[i]*1.5f; System.out.println("Apresentan o conteú vetor A e veetor B."); for(i = 0; i < 15; i++) System.out.println("A[" + i + "] = " + A[i] + " e B[" + i + "] = " + B[i]);

27 6j) package exercicio.pkg6j; public class Exercicio6j int[] A = new int[6]; int[] B = new int[6]; int[] C = new int[12]; int i; i=0; System.out.print("Digite o " + (i+1) + "º número par vetor A: "); A[i] = leia.nextint(); if(a[i] % 2 == 0) i++; else System.out.println("Você deve entrar com um número par!!!!"); while(i<6); i = 0; System.out.print("Digite o " + (i+1) + "º número ímpar vetor B: "); B[i] = leia.nextint(); if(b[i] % 2 == 1) i++; else System.out.println("Você deve entrar com um número ímpar!!!!"); while(i<6); for(i = 0; i < 6; i++) C[i] = A[i]; C[6+i] = B[i]; System.out.println("Apresentan o conteú vetor C."); for(i = 0; i < 12; i++) System.out.println("C[" + i + "] = " + C[i]);

Prof. Navrati Saxena TA: Rochak Sachan

Prof. Navrati Saxena TA: Rochak Sachan JAVA Prof. Navrati Saxena TA: Rochak Sachan Operators Operator Arithmetic Relational Logical Bitwise 1. Arithmetic Operators are used in mathematical expressions. S.N. 0 Operator Result 1. + Addition 6.

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

Selenium Class 9 - Java Operators

Selenium Class 9 - Java Operators Selenium Class 9 - Java Operators Operators are used to perform Arithmetic, Comparison, and Logical Operations, Operators are used to perform operations on variables and values. public class JavaOperators

More information

CSCI 135 Exam #0 Fundamentals of Computer Science I Fall 2013

CSCI 135 Exam #0 Fundamentals of Computer Science I Fall 2013 CSCI 135 Exam #0 Fundamentals of Computer Science I Fall 2013 Name: This exam consists of 7 problems on the following 6 pages. You may use your single- side hand- written 8 ½ x 11 note sheet during the

More information

6 COMPUTER PROGRAMMING

6 COMPUTER PROGRAMMING 6 COMPUTER PROGRAMMING ITERATION STATEMENT CONTENTS WHILE DO~WHILE FOR statement 2 Iteration Statement provides While / do-while / For statements for supporting an iteration logic function that the logic

More information

Sequence structure. The computer executes java statements one after the other in the order in which they are written. Total = total +grade;

Sequence structure. The computer executes java statements one after the other in the order in which they are written. Total = total +grade; Control Statements Control Statements All programs could be written in terms of only one of three control structures: Sequence Structure Selection Structure Repetition Structure Sequence structure The

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

Computational Expression

Computational Expression Computational Expression Conditionals Janyl Jumadinova 10 October, 2018 Janyl Jumadinova Computational Expression 10 October, 2018 1 / 16 Computational Thinking: a problem solving process Decomposition

More information

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

JAVA PROGRAMMING LAB. ABSTRACT In this Lab you will learn to define and invoke void and return java methods Islamic University of Gaza Faculty of Engineering Computer Engineering Dept. Computer Programming Lab (ECOM 2114) ABSTRACT In this Lab you will learn to define and invoke void and return java methods JAVA

More information

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

Java provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following groups: Basic Operators 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

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

bitwise inclusive OR Logical logical AND && logical OR Ternary ternary? : Assignment assignment = += -= *= /= %= &= ^= = <<= >>= >>>= Operators in java Operator in java is a symbol that is used to perform operations. For example: +, -, *, / etc. There are many types of operators in java which are given below: Unary Operator, Arithmetic

More information

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

More on methods and variables. Fundamentals of Computer Science Keith Vertanen More on methods and variables Fundamentals of Computer Science Keith Vertanen Terminology of a method Goal: helper method than can draw a random integer between start and end (inclusive) access modifier

More information

Day 2 : Intermediate Concepts 1 Examples

Day 2 : Intermediate Concepts 1 Examples Example1 Day 2 : Intermediate Concepts 1 Examples public class Example1 public static void main(string[] args) int a= 5, b = 10, c = 15, d= 20; Assignment int x = a++; a is assigned to x and then increment

More information

Lara Technologies Special-Six Test

Lara Technologies Special-Six Test Flow control Part-1 Q: 01 Given: 10. public class Bar 11. static void foo( int... x ) 12. // insert code here 13. 14. Which two code fragments, inserted independently at line 12, will allow the class to

More information

Exam 2. Programming I (CPCS 202) Instructor: M. G. Abbas Malik. Total Marks: 40 Obtained Marks:

Exam 2. Programming I (CPCS 202) Instructor: M. G. Abbas Malik. Total Marks: 40 Obtained Marks: كلية الحاسبات وتقنية المعلوما Exam 2 Programming I (CPCS 202) Instructor: M. G. Abbas Malik Date: November 22, 2015 Student Name: Student ID: Total Marks: 40 Obtained Marks: Instructions: Do not open this

More information

5) (4 points) What is the value of the boolean variable equals after the following statement?

5) (4 points) What is the value of the boolean variable equals after the following statement? For problems 1-5, give a short answer to the question. (15 points, ~8 minutes) 1) (4 points) Write four Java statements that declare and initialize the following variables: A) a long integer with the value

More information

AP COMPUTER SCIENCE A

AP COMPUTER SCIENCE A AP COMPUTER SCIENCE A CONTROL FLOW Aug 28 2017 Week 2 http://apcs.cold.rocks 1 More operators! not!= not equals to % remainder! Goes ahead of boolean!= is used just like == % is used just like / http://apcs.cold.rocks

More information

Question Bank. 4. Write a menu driven program to accept two numbers and find a. HCF / GCD b. LCM

Question Bank. 4. Write a menu driven program to accept two numbers and find a. HCF / GCD b. LCM Question Bank 1. Write a program using over loading function with name as area to calculate a. Area of a square (side * side) b. Area of a rectangle (length * breadth) c. Area of a circle. ( * radius *

More information

Java Simple Data Types

Java Simple Data Types Intro to Java Unit 1 Multiple Choice Test Key Java Simple Data Types This Test Is a KEY DO NOT WRITE ON THIS TEST This test includes program segments, which are not complete programs. Answer such questions

More information

Java Programming Language. 0 A history

Java Programming Language. 0 A history Java Programming Language 0 A history How java works What you ll do in Java JVM API Java Features 0Platform Independence. 0Object Oriented. 0Compiler/Interpreter 0 Good Performance 0Robust. 0Security 0

More information

Principles of Computer Science

Principles of Computer Science Principles of Computer Science Lecture 2 Dr. Horia V. Corcalciuc Horia Hulubei National Institute for R&D in Physics and Nuclear Engineering (IFIN-HH) January 27, 2016 Loops: do-while do-while loops do

More information

Glossary. (Very) Simple Java Reference (draft, v0.2)

Glossary. (Very) Simple Java Reference (draft, v0.2) (Very) Simple Java Reference (draft, v0.2) (Very) Simple Java Reference (draft, v0.2) Explanations and examples for if and for (other things to-be-done). This is supposed to be a reference manual, so we

More information

Term 1 Unit 1 Week 1 Worksheet: Output Solution

Term 1 Unit 1 Week 1 Worksheet: Output Solution 4 Term 1 Unit 1 Week 1 Worksheet: Output Solution Consider the following what is output? 1. System.out.println("hot"); System.out.println("dog"); Output hot dog 2. System.out.print("hot\n\t\t"); System.out.println("dog");

More information

CS111: PROGRAMMING LANGUAGE II

CS111: PROGRAMMING LANGUAGE II CS111: PROGRAMMING LANGUAGE II Computer Science Department Lecture 1(c): Java Basics (II) Lecture Contents Java basics (part II) Conditions Loops Methods Conditions & Branching Conditional Statements A

More information

University of Massachusetts Amherst, Electrical and Computer Engineering

University of Massachusetts Amherst, Electrical and Computer Engineering University of Massachusetts Amherst, Electrical and Computer Engineering ECE 122 Midterm Exam 1 Makeup Answer key March 2, 2018 Instructions: Closed book, Calculators allowed; Duration:120 minutes; Write

More information

Prof. Edwar Saliba Júnior

Prof. Edwar Saliba Júnior 1 package Conexao; 2 3 4 * 5 * @author Cynthia Lopes 6 * @author Edwar Saliba Júnior 7 8 import java.io.filenotfoundexception; 9 import java.io.ioexception; 10 import java.sql.sqlexception; 11 import java.sql.statement;

More information

Object-Oriented Programming and Software Engineering CITS1001 MID-SEMESTER TEST

Object-Oriented Programming and Software Engineering CITS1001 MID-SEMESTER TEST Object-Oriented Programming and Software Engineering School of Computer Science & Software Engineering The University of Western Australia CITS1001 MID-SEMESTER TEST Semester 1, 2013 CITS1001 This Paper

More information

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

Java provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following groups: 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

Key Java Simple Data Types

Key Java Simple Data Types AP CS P w Java Unit 1 Multiple Choice Practice Key Java Simple Data Types This test includes program segments, which are not complete programs. Answer such questions with the assumption that the program

More information

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.

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. Grading Page 1 / 4 Page3 / 20 Page 4 / 13 Page 5 / 10 Page 6 / 26 Page 7 / 17 Page 8 / 10 Total / 100 1. (4 points) What is your course section? CS 101 CS 101E Pledged Page 1 of 8 Pledged The following

More information

For that purpose, java provides control structures that serve to specify what has to be done by our program, when and under which circumstances.

For that purpose, java provides control structures that serve to specify what has to be done by our program, when and under which circumstances. Control Structures A program is usually not limited to a linear sequence of instructions. During its process it may bifurcate, repeat code or take decisions. For that purpose, java provides control structures

More information

Operators Questions

Operators Questions Operators Questions https://www.geeksforgeeks.org/java-operators-question-1/ https://www.indiabix.com/java-programming/operators-andassignments/ http://www.instanceofjava.com/2015/07/increment-decrementoperators-interview.html

More information

University of Palestine. Mid Exam Total Grade: 100

University of Palestine. Mid Exam Total Grade: 100 First Question No. of Branches (5) A) Choose the correct answer: 1. If we type: system.out.println( a ); in the main() method, what will be the result? int a=12; //in the global space... void f() { int

More information

DM550 / DM857 Introduction to Programming. Peter Schneider-Kamp

DM550 / DM857 Introduction to Programming. Peter Schneider-Kamp DM550 / DM857 Introduction to Programming Peter Schneider-Kamp petersk@imada.sdu.dk http://imada.sdu.dk/~petersk/dm550/ http://imada.sdu.dk/~petersk/dm857/ CALLING & DEFINING FUNCTIONS 2 Functions and

More information

CONDITIONAL EXECUTION

CONDITIONAL EXECUTION CONDITIONAL EXECUTION yes x > y? no max = x; max = y; logical AND logical OR logical NOT &&! Fundamentals of Computer Science I Outline Conditional Execution if then if then Nested if then statements Comparisons

More information

Prelim 1. CS 2110, 13 March 2018, 5:30 PM Total Question Name Short answer

Prelim 1. CS 2110, 13 March 2018, 5:30 PM Total Question Name Short answer Prelim 1 CS 2110, 13 March 2018, 5:30 PM 1 2 3 4 5 6 Total Question Name Short answer Exception handling Recursion OO Loop invariants Max 1 30 11 14 30 14 100 Score Grader The exam is closed book and closed

More information

CS180. Exam 1 Review

CS180. Exam 1 Review CS180 Exam 1 Review What is the output to the following code? System.out.println("2 + 2 = " + (2 + 2)); System.out.println("2 + 2 = " + 2 + 2); What is the output to the following code? System.out.println(String.valueOf(15+20));

More information

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

Programming Basics.  Digital Urban Visualization. People as Flows. ia Programming Basics Digital Urban Visualization. People as Flows. 28.09.2015 ia zuend@arch.ethz.ch treyer@arch.ethz.ch Programming? Programming is the interaction between the programmer and the computer.

More information

Java Programming for Selenium

Java Programming for Selenium Video 5 - Java Control Flow, String Handling and Arrays Java Programming for Selenium 1) Conditional / Decision Making 2) Loop 3) Branching 4) String Handling in Java 5) Java Arrays 1) Conditional / Decision

More information

Java Simple Data Types

Java Simple Data Types 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

More information

CompSci 125 Lecture 11

CompSci 125 Lecture 11 CompSci 125 Lecture 11 switch case The? conditional operator do while for Announcements hw5 Due 10/4 p2 Due 10/5 switch case! The switch case Statement Consider a simple four-function calculator 16 buttons:

More information

Spring 2013 COMP Midterm Exam Solutions March 07, 2013

Spring 2013 COMP Midterm Exam Solutions March 07, 2013 Spring 2013 COMP 110-003 Midterm Exam Solutions March 07, 2013 UNC Honor Pledge: I certify that no unauthorized assistance has been received or given in the completion of this work. Signature: Read this

More information

Decision Making and Loops

Decision Making and Loops Decision Making and Loops Goals of this section Continue looking at decision structures - switch control structures -if-else-if control structures Introduce looping -while loop -do-while loop -simple for

More information

CMPS 12A - Winter 2002 Midterm 2 March 5, Name: ID:

CMPS 12A - Winter 2002 Midterm 2 March 5, Name: ID: CMPS 12A - Winter 2002 Midterm 2 March 5, 2002 Name: ID: This is a closed note, closed book exam. Any place where you are asked to write code, you must declare all variables that you use. However, I just

More information

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

Section 003 Fall CS 170 Exam 2. Name (print): Instructions: CS 170 Exam 2 Section 003 Fall 2012 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

(c) ((!(a && b)) == (!a!b)) TRUE / FALSE. (f) ((!(a b)) == (!a &&!b)) TRUE / FALSE. (g) (!(!a) && (c-d > 0) && (b!b))

(c) ((!(a && b)) == (!a!b)) TRUE / FALSE. (f) ((!(a b)) == (!a &&!b)) TRUE / FALSE. (g) (!(!a) && (c-d > 0) && (b!b)) ComS 207: Programming I Midterm 2, Tue. Mar 21, 2006 Student Name: Student ID Number: Recitation Section: 1. True/False Questions (10 x 1p each = 10p) Determine the value of each boolean expression given

More information

Selection Statements and operators

Selection Statements and operators Selection Statements and operators CSC 1051 Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website: www.csc.villanova.edu/~map/1051/

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

Java Programming Language Mr.Rungrote Phonkam

Java Programming Language Mr.Rungrote Phonkam 3 Java Programming Language Mr.Rungrote Phonkam rungrote@it.kmitl.ac.th Contents 1. Identify 2. Method Member 3. Literals 4. Data Type 6. Variable 1. Identify ก ก Class, Data, Method, Variable, Label,

More information

1. Basics 1. Write a program to add any two-given integer. Algorithm Code 2. Write a program to calculate the volume of a given sphere Formula Code

1. Basics 1. Write a program to add any two-given integer. Algorithm Code  2. Write a program to calculate the volume of a given sphere Formula Code 1. Basics 1. Write a program to add any two-given integer. Algorithm - 1. Start 2. Prompt user for two integer values 3. Accept the two values a & b 4. Calculate c = a + b 5. Display c 6. Stop int a, b,

More information

Chapter 18: Repetitive Structures

Chapter 18: Repetitive Structures Chapter 18: Repetitive Structures Practice Questions A. Answer the following questions: 1. What is a loop? Discuss Elements that Control a Loop. Ans. Loop is a repetitive structure that allows a group

More information

Guru Gobind Singh Public School Sector V,B Bokaro Steel City Annual IP Assignment Class 11

Guru Gobind Singh Public School Sector V,B Bokaro Steel City Annual IP Assignment Class 11 Guru Gobind Singh Public School Sector V,B Bokaro Steel City Annual IP Assignment Class 11 1. What will be the output of given expression : int a=7; System.out.println(++a + + a-- + + a+1 + +a++); System.out.println(a);

More information

First Exam/Second Test 19/6/2010

First Exam/Second Test 19/6/2010 Instituto Superior Técnico Programação Avançada First Exam/Second Test 19/6/2010 Name: Number: Write your number on every page. Your answers should not be longer than the available space. You can use the

More information

Tasks for fmri-setting (Tasks of first and second pilot study at the end)

Tasks for fmri-setting (Tasks of first and second pilot study at the end) Tasks for fmri-setting (Tasks of first and second pilot study at the end) 1. Faculty int result = 1; int x = 4; while (x > 1) { result = result * x; x--; 7. Find max in list of numbers public static void

More information

CS 101 Fall 2005 Midterm 2 Name: ID:

CS 101 Fall 2005 Midterm 2 Name:  ID: This exam is open text book but closed-notes, closed-calculator, closed-neighbor, etc. Questions are worth different amounts (in particular, the final two questions are worth substantially more than any

More information

Place your name tag here

Place your name tag here CS 170 Exam 1 Section 001 Spring 2015 Name: Place your name tag here Instructions: Keep your eyes on your own paper and do your best to prevent anyone else from seeing your work. Do NOT communicate with

More information

CSE 201 JAVA PROGRAMMING I. Copyright 2016 by Smart Coding School

CSE 201 JAVA PROGRAMMING I. Copyright 2016 by Smart Coding School CSE 201 JAVA PROGRAMMING I Primitive Data Type Primitive Data Type 8-bit signed Two s complement Integer -128 ~ 127 Primitive Data Type 16-bit signed Two s complement Integer -32768 ~ 32767 Primitive Data

More information

1 class Lecture3 { 2 3 "Selections" // Keywords 8 if, else, else if, switch, case, default. Zheng-Liang Lu Java Programming 89 / 137

1 class Lecture3 { 2 3 Selections // Keywords 8 if, else, else if, switch, case, default. Zheng-Liang Lu Java Programming 89 / 137 1 class Lecture3 { 2 3 "Selections" 4 5 } 6 7 // Keywords 8 if, else, else if, switch, case, default Zheng-Liang Lu Java Programming 89 / 137 Flow Controls The basic algorithm (and program) is constituted

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

CSC240 Static method, array, and loop.

CSC240 Static method, array, and loop. CSC240 Static method, array, and loop. 1. Tracing programs Code public class Quiz1 public static void main(string [] args) String x = mystery("00"); public static String mystery(string s) s = s + "7";

More information

Java Control Statements

Java Control Statements Java Control Statements An introduction to the Java Programming Language Produced by: Eamonn de Leastar (edeleastar@wit.ie) Dr. Siobhan Drohan (sdrohan@wit.ie) Department of Computing and Mathematics http://www.wit.ie/

More information

Chapter 4 Loops. Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved.

Chapter 4 Loops. Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved. Chapter 4 Loops 1 Motivations Suppose that you need to print a string (e.g., "Welcome to Java!") a hundred times. It would be tedious to have to write the following statement a hundred times: So, how do

More information

Practice with variables and types

Practice with variables and types Practice with variables and types 1. Types. For each literal or expression, state its type (String, int, double, or boolean). Expression Type Expression Type 387 "pancakes" true 45.0 "14" 87.98515 "false"

More information

IEEE Floating-Point Representation 1

IEEE Floating-Point Representation 1 IEEE Floating-Point Representation 1 x = ( 1) s M 2 E The sign s determines whether the number is negative (s = 1) or positive (s = 0). The significand M is a fractional binary number that ranges either

More information

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

CSCE 145 Exam 1 Review Answers. This exam totals to 100 points. Follow the instructions. Good luck! CSCE 145 Exam 1 Review Answers This exam totals to 100 points. Follow the instructions. Good luck! Chapter 1 This chapter was mostly terms so expect a fill in the blank style questions on definition. Remember

More information

Arithmetic Compound Assignment Operators

Arithmetic Compound Assignment Operators Arithmetic Compound Assignment Operators Note that these shorthand operators are not available in languages such as Matlab and R. Zheng-Liang Lu Java Programming 76 / 141 Example 1... 2 int x = 1; 3 System.out.println(x);

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

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

1 class Lecture3 { 2 3 "Selections" // Keywords 8 if, else, else if, switch, case, default. Zheng-Liang Lu Java Programming 88 / 133

1 class Lecture3 { 2 3 Selections // Keywords 8 if, else, else if, switch, case, default. Zheng-Liang Lu Java Programming 88 / 133 1 class Lecture3 { 2 3 "Selections" 4 5 } 6 7 // Keywords 8 if, else, else if, switch, case, default Zheng-Liang Lu Java Programming 88 / 133 Flow Controls The basic algorithm (and program) is constituted

More information

IST 297D Introduction to Application Programming Chapter 4 Problem Set. Name:

IST 297D Introduction to Application Programming Chapter 4 Problem Set. Name: IST 297D Introduction to Application Programming Chapter 4 Problem Set Name: 1. Write a Java program to compute the value of an investment over a number of years. Prompt the user to enter the amount of

More information

DM503 Programming B. Peter Schneider-Kamp.

DM503 Programming B. Peter Schneider-Kamp. DM503 Programming B Peter Schneider-Kamp petersk@imada.sdu.dk! http://imada.sdu.dk/~petersk/dm503/! VARIABLES, EXPRESSIONS & STATEMENTS 2 Values and Types Values = basic data objects 42 23.0 "Hello!" Types

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

Output :: /* display results */ System.out.print( Call Duration: );

Output :: /* display results */ System.out.print( Call Duration: ); Introduction 7 : JAVA BASICS Java is object oriented programming language developed by Sun Microsystems in 1991. A company best known for its high-end UNIX workstations. Modelled after C++ Java language

More information

This page intentionally left blank

This page intentionally left blank This page intentionally left blank Arrays and References 391 Since an indexed variable of the array a is also a variable of type double, just like n, the following is equally legal: mymethod(a[3]); There

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

Introduction to Programming Written Examination

Introduction to Programming Written Examination Introduction to Programming Written Examination 23.9.2016 FIRST NAME STUDENT NUMBER LAST NAME SIGNATURE Instructions for students: Write First Name, Last Name, Student Number and Signature where indicated.

More information

CSC 1051 Data Structures and Algorithms I

CSC 1051 Data Structures and Algorithms I Repetition CSC 1051 Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website: www.csc.villanova.edu/~map/1051/ Some slides in this

More information

16. Give a detailed algorithm for making a peanut butter and jelly sandwich.

16. Give a detailed algorithm for making a peanut butter and jelly sandwich. COSC120FinalExamReview2010 1. NamethetwotheoreticalmachinesthatCharlesBabbagedeveloped. 2. WhatwastheAntikytheraDevice? 3. Givethecodetodeclareanintegervariablecalledxandthenassignitthe number10. 4. Givethecodetoprintout

More information

Interfaces Java. Overview. n Java interfaces. q Introduction. q Sintaxe. q UML notation. q Multi-inheritance of interfaces

Interfaces Java. Overview. n Java interfaces. q Introduction. q Sintaxe. q UML notation. q Multi-inheritance of interfaces Interfaces Java jvo@ualg.pt José Valente de Oliveira 11-1 Overview n Java interfaces q Introduction q Sintaxe q UML notation q Multi-inheritance of interfaces q (Some) Java pre-defined interfaces q Design

More information

For that purpose, java provides control structures that serve to specify what has to be done by our program, when and under which circumstances.

For that purpose, java provides control structures that serve to specify what has to be done by our program, when and under which circumstances. Control Structures A program is usually not limited to a linear sequence of instructions. During its process it may bifurcate, repeat code or take decisions. For that purpose, java provides control structures

More information

Practice with variables and types

Practice with variables and types Practice with variables and types 1. Types. For each literal or expression, state its type (String, int, double, or boolean). Expression Type Expression Type 387 int "pancakes" String true boolean 45.0

More information

Top-down programming design

Top-down programming design 1 Top-down programming design Top-down design is a programming style, the mainstay of traditional procedural languages, in which design begins by specifying complex pieces and then dividing them into successively

More information

Motivating Examples (1.1) Selections. Motivating Examples (1.2) Learning Outcomes. EECS1022: Programming for Mobile Computing Winter 2018

Motivating Examples (1.1) Selections. Motivating Examples (1.2) Learning Outcomes. EECS1022: Programming for Mobile Computing Winter 2018 Motivating Examples (1.1) Selections EECS1022: Programming for Mobile Computing Winter 2018 CHEN-WEI WANG 1 import java.util.scanner; 2 public class ComputeArea { 3 public static void main(string[] args)

More information

Basic computer skills such as using Windows, Internet Explorer, and Microsoft Word. and Java. Chapter 2 Primitive Data Types and Operations

Basic computer skills such as using Windows, Internet Explorer, and Microsoft Word. and Java. Chapter 2 Primitive Data Types and Operations Basic computer skills such as using Windows, Internet Explorer, and Microsoft Word Chapter p 1 Introduction to Computers, p, Programs, g, and Java Chapter 2 Primitive Data Types and Operations Chapter

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

CMP 326 Midterm Fall 2015

CMP 326 Midterm Fall 2015 CMP 326 Midterm Fall 2015 Name: 1) (30 points; 5 points each) Write the output of each piece of code. If the code gives an error, write any output that would happen before the error, and then write ERROR.

More information

CMPS 12A - Winter 2002 Final Exam A March 16, Name: ID:

CMPS 12A - Winter 2002 Final Exam A March 16, Name: ID: CMPS 12A - Winter 2002 Final Exam A March 16, 2002 Name: ID: This is a closed note, closed book exam. Any place where you are asked to write code, you must declare all variables that you use. However,

More information

CIS 120 Programming Languages and Techniques. Midterm II. November 12, 2010

CIS 120 Programming Languages and Techniques. Midterm II. November 12, 2010 CIS 120 Programming Languages and Techniques Midterm II November 12, 2010 Name: Pennkey: Scores: 1 2 3 4 5 6 Total (50 max) 1. (14 points) Pages 7 to 9 define a simplified version of the Java Collection

More information

ENGR 2710U Midterm Exam UOIT SOLUTION SHEET

ENGR 2710U Midterm Exam UOIT SOLUTION SHEET SOLUTION SHEET ENGR 2710U: Object Oriented Programming & Design Midterm Exam October 19, 2012, Duration: 80 Minutes (9 Pages, 14 questions, 100 Marks) Instructor: Dr. Kamran Sartipi Name: Student Number:

More information

Selections. EECS1021: Object Oriented Programming: from Sensors to Actuators Winter 2019 CHEN-WEI WANG

Selections. EECS1021: Object Oriented Programming: from Sensors to Actuators Winter 2019 CHEN-WEI WANG Selections EECS1021: Object Oriented Programming: from Sensors to Actuators Winter 2019 CHEN-WEI WANG Learning Outcomes The Boolean Data Type if Statement Compound vs. Primitive Statement Common Errors

More information

CIS November 27, 2018

CIS November 27, 2018 CIS 1068 November 27, 2018 Administrative Stuff Midterm 2 today in-lab this week dups Assignment 10 Last Time our SmartArray ArrayList ArrayList useful no need to memorize. add to cheat sheet Generics.

More information

«ï è : Fibonacci ªî ì ó Ü C C++ Gó ô â î. Pº ø : àœk : Enter the value of N : 5. ªõOf : Fibonacci Series. «ï è : ªî ì ªð ¼ è ô è ìp» C++ Gó ô â î

«ï è : Fibonacci ªî ì ó Ü C C++ Gó ô â î. Pº ø : àœk : Enter the value of N : 5. ªõOf : Fibonacci Series. «ï è : ªî ì ªð ¼ è ô è ìp» C++ Gó ô â î Ex:B1 Fibonacci Series «ï è : Fibonacci ªî ì ó Ü C C++ Gó ô â î int f1=0, f2=1, f3, n, i; cout < < "\nenter the value of N : "; cin >> n ; cout < < "\n\nfibonacci Series\n"; cout < < f1 < < "\t" < < f2

More information

CIS 120 Programming Languages and Techniques. Midterm II. November 12, Answer key

CIS 120 Programming Languages and Techniques. Midterm II. November 12, Answer key CIS 120 Programming Languages and Techniques Midterm II November 12, 2010 Answer key 1. (14 points) Pages 7 to 9 define a simplified version of the Java Collection interface (the SimpleCollection and SimpleIterator

More information

CIS202 Exam 1 1. Convert from base 2 to base 10 (4 points)

CIS202 Exam 1 1. Convert from base 2 to base 10 (4 points) CIS202 Exam 1 1. Convert 10100011 from base 2 to base 10 (4 points) Name: 163 2. Convert the 57 from base 10 to base 2 (4 points) 00111001 3. What are the values of the following expressions? (18 points)

More information

Logic is the anatomy of thought. John Locke ( ) This sentence is false.

Logic is the anatomy of thought. John Locke ( ) This sentence is false. Logic is the anatomy of thought. John Locke (1632 1704) This sentence is false. I know that I know nothing. anonymous Plato (In Apology, Plato relates that Socrates accounts for his seeming wiser than

More information

CSE 1223: Introduction to Computer Programming in Java Chapter 3 Branching

CSE 1223: Introduction to Computer Programming in Java Chapter 3 Branching CSE 1223: Introduction to Computer Programming in Java Chapter 3 Branching 1 Flow of Control The order in which statements in a program are executed is called the flow of control So far we have only seen

More information

1.Why do we use OPP (Object Oriented Programming) in Java?

1.Why do we use OPP (Object Oriented Programming) in Java? 1 1.Why do we use OPP (Object Oriented Programming) in Java? a. To create multiple instances of the one object. b. To make the program run c. To allow for creation of objects d. To organize the code and

More information

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

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

More information

3-Rewrite the following program code using a Switch statement: 2

3-Rewrite the following program code using a Switch statement: 2 PRACTICE PAPER-IP CONVERSION 1-Rewrite the code using switch.case. 2 int a=3; if(a= =3) System.out.println( Number is odd ); if(a= =7) System.out.println( Number is odd ); if(a= =5) System.out.println(

More information

1. An operation in which an overall value is computed incrementally, often using a loop.

1. An operation in which an overall value is computed incrementally, often using a loop. Practice Exam 2 Part I: Vocabulary (10 points) Write the terms defined by the statements below. 1. An operation in which an overall value is computed incrementally, often using a loop. 2. The < (less than)

More information