Computer Science 1 Final

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

/* and */, or just using // over many lines.

How can you rewrite a comment so it can appear over many lines instead of just one?

public int Finals (int x) {

How do you begin a method called "Finals" that is passed an integer value and returns an integer value?

public boolean Check (int x, int y) {

How do you begin a method that accepts two passed int values and returns true if they are equal to each other and false if they are not?

public class Meme {

How do you define a class called "Meme"?

1 line of output

public class January { public static void main(String[] args) { System.out.print("January"); System.out.print("is " + "cold"); System.out.print("in Wisconsin"); } } How many lines of output will there be?

"Januaryis coldin Wisonsin"

public class January { public static void main(String[] args) { System.out.print("January"); System.out.print("is " + "cold"); System.out.print("in Wisconsin"); } } What will the program output?

Things the object can do

What is a method?

A parameter, characteristics of an object

What is a property?

Instance of a class

What is an object?

14

What is the base 10 translation of the binary number 1110?

10101

What is the binary equivalent of 21?

new

What reserved word in Java is used to create an instance of a class?

x will be 3

if (a > 0) if (b < 0) x = x + 5; else if (a > 5) x = x + 4; else x = x + 3; else x = x + 2; Considering the nested if structure above, if x = 0, a = 5, and b = 5, what will x be after the statement executes?

6 times

int x = 6; while (x > 0) { System.out.println(x); x--; } How many times will the loop iterate?

m2

Consider the following method invocations: main calls m1, m1 calls m2, m2 calls m3 and then m2 calls m4, m3 calls m5. If m3 has just terminated, what method will resume execution?

3

System.out.println(x-y); If x and y are int values where x=5 and y=2, what is the output of the statement?

Objects are instances of classes

The relationship between a class and an object can be described as...

Blueprint of an object

What is a class?

120 times

for(int j = 0; j < 10; j++) for(int k = 12; k > 0; k--) x++; The nested loop structure will execute the inner most statement (x++) how many times?

"5"

public class Swapper { private int x; private String y; public int z; public Swapper(int a, String b, int c) { x = z; y = b; z = c; } public int swap( ) { int temp = x; x = z; z = temp; return z; } public String toString( ) { if (x < z) return y; else return "" + x + z; } If Swapper r = new Swapper (5, "hi", 10); then r.swap( ); returns what value?

"turtle"

public class Swapper { private int x; private String y; public int z; public Swapper(int a, String b, int c) { x = z; y = b; z = c; } public int swap( ) { int temp = x; x = z; z = temp; return z; } public String toString( ) { if (x < z) return y; else return "" + x + z; } If the instruction Swapper s = new Swapper(1, "turtle", 5); is executed followed by x.toString( ); what value is returned from s.toString( )?


Set pelajaran terkait

Personal Finance Chapter 7 Study Guide

View Set

Final Quiz - Chapter 26 and Appendix D

View Set

International Marketing Ch 7, 8, 12

View Set