int january; and
int[] month;.
Given that, provide the best answer to each.
| (1) |
_____
|
In the Java statement
january = new month[12];,
new is: |
|
||
| (2) |
_____
|
In the Java statement
january = month[0];,
january is: |
|
||
| (3) |
_____
|
In the Java statement
january = month[0];,
= is: |
|
||
| (4) |
_____
|
In the Java statement
january = month[0];,
month is: |
|
||
| (5) |
_____
|
In the Java statement
january = month[0];,
[] is: |
|
public static int vowelCounter(String s) {
char letter;
int n;
int vowels;
String lc;
lc = s.toLowerCase();
n = s.length();
for (int i=0; i<n; i++) {
letter = lc.charAt(i);
if ((letter == 'a') || (letter == 'e') || (letter == 'i') ||
(letter == 'o') || (letter == 'u')) {
vowels++;
}
return vowels;
}
Identify the best description of each of the following as it is used (explicitly or implicitly) in this fragment. You may use a description more than once.
|
|
String dept;
dept.toLowerCase();
|
|
|
|
|
String dept;
dept = new String("cs");
dept.toUpperCase();
|
|
|
|
|
String dept;
dept = new String("cs");
dept = dept.toUpperCase();
|
|
|
|
|
String dept;
String code;
dept = new String("cs");
code = dept.toUpperCase();
|
|
|
|
|
String course;
course = new String("CS") + new String("149");
|
|
|
|
|
int[] scores;
scores = 5;
|
|
|
|
|
int[] scores;
scores[0] = 5;
|
|
|
|
|
int[] scores;
scores = new int[10];
scores[10] = 5;
|
|
|
|
|
int[] scores;
scores = new int[5];
int n;
n = scores.length;
|
|
|
|
|
int[] scores;
scores = new int[5];
scores.length = 10;
|
|
|
|
|
int[] scores;
scores = new int[10];
scores = new int[20];
|
|
|
|
|
int[] scores;
scores = new int[10];
scores[0] = 100;
|
|
|
|
|
int[] scores;
scores = new int[10];
scores[0] = 100.0;
|
|
|
|
|
int[] scores;
scores = new int[10];
for (int i=0; i<scores.length; i++) {
scores[0] = 0.0;
}
|
|
|
|
|
int[] scores;
scores = new int[10];
for (int i=0; i>0; i++) {
scores[i] = 0.0;
}
|
|
|
|
|
In the following fragment:
String star;
String costar;
star = new String("Fred");
costar = new String("Wilma");
if (star == costar) {
System.out.println("Here");
}
the expression |
|
|
|
|
In the following fragment:
String star;
String costar;
star = new String("Fred");
costar = new String("Fred");
if (star == costar) {
System.out.println("Here");
}
the expression |
|
|
|
|
In the following fragment:
String star;
String costar;
star = new String("Fred");
costar = new String("Fred");
if (star.equals(costar)) {
System.out.println("Here");
}
the expression |
|
|
|
|
In the following fragment:
int[] week1 = {0, 1, 2, 3, 4, 5, 6, 7};
int[] week2 = {0, 1, 2, 3, 4, 5, 6, 7};
if (week1 == week2) {
System.out.println("Here");
}
the expression |
|
|
|
|
In the following fragment:
int[] week1 = {0, 1, 2, 3, 4, 5, 6, 7};
int[] week2 = {0, 1, 2, 3, 4, 5, 6, 7};
boolean equal = true;
for (int i=0; i<week1.length; i++) {
if (week1[i] != week2[i]) {
equal = false;
}
}
the variable |
|
|
|
|
Copyright 2020