Analyze the following code.
```
class TempClass {
int i;
public void TempClass(int j) {
int i = j;
}
}
public class C {
public static void main(String[] args) {
TempClass temp = new TempClass(2);
}
}```
a. The program has a compile error because TempClass does not have a default constructor.
b. The program has a compile error because TempClass does not have a constructor with an int argument.
c. The program compiles fine, but it does not run because class C is not public.
d. The program compiles and runs fine.
b The program would be fine if the void keyword is removed from public void TempClass(int j).
You might also like to view...
Each SharePoint site is a collection of pages managed by a Document library
Indicate whether the statement is true or false
Suppose that ch1 and ch2 are char variables, and alpha is an int variable. The input is: ? A 18 ? What are the values after the following statement executes? ? cin.get(ch1); cin.get(ch2); cin >> alpha; ?
A. ch1 = 'A', ch2 = ' ', alpha = 18 B. ch1 = 'A', ch2 = '1', alpha = 8 C. ch1 = 'A', ch2 = ' ', alpha = 1 D. ch1 = 'A', ch2 = '\n', alpha = 1