Quiz 11 February 13, 2019.

Slides:



Advertisements
Similar presentations
Continuation of chapter 6…. Nested while loop A while loop used within another while loop is called nested while loop. Q. An illustration to generate.
Advertisements

8 March 2013Birkbeck College, U. London1 Introduction to Programming Lecturer: Steve Maybank Department of Computer Science and Information Systems
For(int i = 1; i
What is output line of the following C++ code? Please trace int i = 1, QP; DATA: 4, B, 3, A double credit, totCredit=0.0; double num = 0.0; string LG;
Picture It Very Basic Game Picture Pepper. Original Game import java.util.Scanner; public class Game { public static void main() { Scanner scan=new Scanner(System.in);
INHERITANCE BASICS Reusability is achieved by INHERITANCE
INTERFACES IN JAVA 1.Java Does not support Multiple Inheritance directly. Multiple inheritance can be achieved in java by the use of interfaces. 2.We need.
METHOD OVERRIDING Sub class can override the methods defined by the super class. Overridden Methods in the sub classes should have same name, same signature.
Types, Variables and Operators Computer Engineering Department Java Course Asst. Prof. Dr. Ahmet Sayar Kocaeli University - Fall 2013.
Chapter 2 Review Questions
Random (1) Random class contains a method to generate random numbers of integer and double type Note: before using Random class, you should add following.
Review. By the end of today you should be able to- Know how to use args Know how to use the JOptionPane Know how to convert a String to a number.
OOPDA Review. Terminology class-A template defining state and behavior class-A template defining state and behavior object-An instance of a class object-An.
Copyright 2008 by Pearson Education 1 Building Java Programs Chapter 2 Lecture 2-1: Expressions and Variables reading:
Shorthand operators.
CS 2430 Day 9. Announcements Quiz on Friday, 9/28 Prog1: see , see me as soon as possible with questions/concerns Prog2: do not add any public methods.
C Programming Lecture 8-2 : Function (advanced). Recursive Function (recursion) A function that calls itself (in its definition) Classic example : factorial.
Java Quiz Bowl A fun review of the Java you should know from CMPT 201 If you don’t know the answers - this week is for you to study up!
PreAP Computer Science Review Quiz 08 Key
Slide 1 Unit Testing. Slide 2 Unit Testing Options l Use N-Unit In a microsoft environment.NET… you can use their supplied N-Unit testing to test your.
1 Variables. 2 Receipt example What's bad about the following code? public class Receipt { public static void main(String[] args) { // Calculate total.
Lecture 8 Using casts, Strings and WordUtil. Agenda Generating random numbers Casts – Casting a double into an int – Casting an int into a char – Casting.
Copyright 2008 by Pearson Education 1 Building Java Programs Chapter 2 Lecture 2-1: Expressions and Variables reading:
1 BUILDING JAVA PROGRAMS CHAPTER 2 PRIMITIVE DATA AND DEFINITE LOOPS.
Mixing integer and floating point numbers in an arithmetic operation.
Classes. Student class We are tasked with creating a class for objects that store data about students. We first want to consider what is needed for the.
Indentation & Readability. What does this program do? public class Hello { public static void main ( String[] args ) { //display initial message System.out.println(
Review TEST 2 Chapters 4,5,7. QUESTION For which type of operands does the == operator always work correctly: (a) int, (b) double, or (c) String?
Copyright 2010 by Pearson Education 1 Building Java Programs Chapter 2 Lecture 2-1: Expressions and Variables reading:
CS 2430 Day 9. Announcements Quiz 2.1 this Friday Program 2 due this Friday at 3pm (grace date Sunday at 10pm)
Side effects A side effect is anything that happens in a method other than computing and/or returning a value. Example: public class hello { public int.
1 Building Java Programs Chapter 2 Lecture 2-1: Expressions and Variables reading:
Martin T. Press.  Main Method and Class Name  Printing To Screen  Scanner.
1 Advanced Programming Examples Output. Show the exact output produced by the following code segment. char[,] pic = new char[6,6]; for (int i = 0; i
Topic 4 Expressions and variables Based on slides bu Marty Stepp and Stuart Reges from "Once a person has understood.
Support standard JavaScript code with static typing Encapsulation through classes and modules Support for constructors, properties and.
Print Row Function void PrintRow(float x[ ][4],int i) { int j; for(j=0;j
1 Printing characters : Revisited class printcharacter{ public static void main(String arg[]){ char grade=‘A’; System.out.println(grade);// prints A System.out.println((int)grade);
Recursion occurs when a method calls itself. Google “recursion”
Output Programs These slides will present a variety of small programs. Each program has a control structure that was introduced in this chapter. Our concern.
Recursion occurs when a method calls itself. public class RecursionOne { public void run(int x) { System.out.println(x); run(x+1); } public static void.
Programming in Java Transitioning from Alice. Becomes not myFirstMethod but …. public static void main (String[] arg) { // code for testing classes goes.
Hello Educational presentation.
Sum of natural numbers class SumOfNaturalNumbers {
Building Java Programs
Register Use Policy Conventions
Computing Adjusted Quiz Total Score
CSC 113 Tutorial QUIZ I.
TO COMPLETE THE FOLLOWING:
Building Java Programs
Building Java Programs
160 Exam 2 Prep.
Java Lesson 36 Mr. Kalmes.
Programming 2 Decision-Making.
Building Java Programs
CS 180 Assignment 6 Arrays.
Building Java Programs Chapter 2
class PrintOnetoTen { public static void main(String args[]) {
PreAP Computer Science Review Quiz 08
Scope of variables class scopeofvars {
Building Java Programs
Building Java Programs
Building Java Programs
Building Java Programs
Building Java Programs Chapter 2
Building Java Programs
Building Java Programs
Chapter 11 Classes.
Building Java Programs
Building Java Programs
Presentation transcript:

Quiz 11 February 13, 2019

public class Test{ int x; static String y; double z; } Code to the left will print public class Test{ int x; static String y; double z; } Hi Hello Hello Hello Hi Hi Hello Hi Correct answer Assuming constructor Test( int x, String y, double z){… } int a=2; String b1=“Hi”, b2=“Hello”; double c= 3.99; Test t1 =new Test(a,b1,c); Test t2 =new Test(a,b2,c); System.out.println(t1.y+ “ “+ t2.y);

public void test(int a, int b){ int temp=a; a=b+1; b=temp; } Code to the left will print public void test(int a, int b){ int temp=a; a=b+1; b=temp; } 18, 11 11, 17 11, 18 17, 17 int x=11; int y=17; test(x,y); System.out.println(x+ “ ,“+ y);