Scanner in = new Scanner(System.in);
System.out.print("Please input an integer ");
int n = in.nextInt();
System.out.println("you input : " + n++);
7?seven?modifying data / discovering itellectual property / invalidating algorithmsthat cause bugs later."
no / slight / moderate / greateffect on the users of the class."
| Ex1.java |
public class Ex1
{
public static int cat;
public int pig;
public static int rat() { return 0; }
public int dog() { return 0; }
} |
Circle the valid calls of the function rat in the
code below:Valid calls bold below public class App1 {
public static void
main(String[] args) {
Ex1 a = new Ex1();
a.rat();
Ex1.rat();
Ex1.a.rat();
a.Ex1.rat();
}
}
|
Circle the valid calls of the function dog in the
code below:Valid calls in bold public class App1 {
public static void
main(String[] args) {
Ex1 a = new Ex1();
a.dog();
Ex1.dog();
Ex1.a.dog();
a.Ex1.dog();
}
}
|
Circle the valid assignments to
pig code below:Valid assignments in bold public class App1
{
public static void
main(String[] args) {
a.pig = 3;
Ex1.pig = 3;
Ex1.a.pig = 3;
a.Ex1.pig = 3;
}
}
|
int i; base String s;;object Angle a;;object double d; base boolean b; base Scanner in;;object char c; base Node n;;object Player p;object
import java.util.*
class Main {
public void main(String args) {
int myArray[10];
for (i=0;i<=10;i++) {
myArray[i] = i;
}
};
import java.util.*;
class Main {
public void main(String [] args) {
int myArray[] =new int[10];
for (i=0;i<10;i++) {
myArray[i] = i;
}
}
public class Foo
{
int i;
public static void swap(int i, int j)
{
int tmp = i;
i = j;
j = tmp;
}
}
Assuming a and b are Foo's, call as:
Foo.swap(a.i,b.j); |
public class Foo
{
int i;
public static void swap(Foo i, Foo j)
{
Foo tmp = i;
i = j;
j = tmp;
}
}
Assuming a and b are Foo's, call as:
Foo.swap(a,b); |
public class Foo
{
int i;
public static void swap(Foo i, Foo j)
{
int tmp;
tmp = i.i;
i.i = j.i;
j.i = tmp;
}
}
Assuming a and b are Foo's, call as:
Foo.swap(a,b); |
if (i <= 40 || charlie[i] == 'x') {
//do something...
if (charlie[i] = 'x' || i <= 40 ) {
//do something...
if (charlie[i] = 'x' || i < 40 ) {
//do something...
};
import java.util.*;
class Main {
public void main(String [] args) {
int myArray[] =new int[10];
for (i=0;i<10;i++) {
myArray[i] = i;
}
}
public class Foo
{
int i;
public static void swap(int i, int j)
{
int tmp = i;
i = j;
j = tmp;
}
}
Assuming a and b are Foo's, call as:
Foo.swap(a.i,b.j); |
public class Foo
{
int i;
public static void swap(Foo i, Foo j)
{
Foo tmp = i;
i = j;
j = tmp;
}
}
Assuming a and b are Foo's, call as:
Foo.swap(a,b); |
public class Foo
{
int i;
public static void swap(Foo i, Foo j)
{
int tmp;
tmp = i.i;
i.i = j.i;
j.i = tmp;
}
}
Assuming a and b are Foo's, call as:
Foo.swap(a,b); |
if (i <= 40 || charlie[i] == 'x') {
//do something...
if (charlie[i] = 'x' || i <= 40 ) {
//do something...
if (charlie[i] = 'x' || i < 40 ) {
//do something...
Main?
| Main.java | Independency.java |
public class Main {
public static void main(String []args) {
int i = -1;
Independency j = new Independency(1,2,3);
int k = j.i(i,5);
System.out.println("result: " + i + " " + j + " " + k);
}
} |
public class Independency {
int i;
int j;
int k;
public Independency(int i,int j, int k) {
this.i = i;
this.j = j;
this.k = k;
}
public int i(int i,int k) {
int j =4;
return i + j;
}
}
|
/** Class representing a book
* @author Prof Crabbe
* @version 0.1
*/
public class Book {
private int year;
private int length;
private Page []pages;
/** year and length constructor
* @param y year of publication
* @param l length of book
*/
public Book(int y,int l) {
year= y;
length = l;
pages = new Page[MAXLENGTH];
}
/** Adds a new page to the book
* @param the page object
*/
public void addPage(Page p) {
pages[size++] = p;
}
/** Finds the page number a string occurs on to help make an index.
* @param s the sring to find
* @return the page number
*/
public int index(String s) {
for(int i = 0; i<size; i++) {
if(pages[i].contains(s))
return i;
}
return MAXLENGTH;
}
}