Question
1. Which one of the following statements about machine code is correct? A. Machine code is similar to English . B. Machine code is stored
1. Which one of the following statements about machine code is correct?
A. Machine code is similar to English .
B. Machine code is stored as binary numbers.
C. Machine code is the output of the Java compiler.
D. Machine code is another name for 'Bytecode'.
2. How are static variables initialized?
A. Static variables are initialized in the same manner as instance variables, but their
values are automatically "final"
B. Static variables are automatically initialized to zero (or whatever zero means for the
particular type)
C. Static variables are initialized, and re-initialized, each time the class (or a method
within the class) is used
D. Static variables are left uninitialized, just like local variables
3. Which of the program segments below will produce the following output?
1
12
123
1234
A. for(int n=1;n<4;n++)
{ for (int k=1;k {System.out.print(n);} System.out.println(); } B. for(int n=1;n<=4;n++) { for (int k=1;k<=n;k++) {System.out.print(n);} System.out.println(); } C. for(int n=1;n<=4;n++) { for (int k=1;k {System.out.print(k);} System.out.println(); } D. for(int n=1;n<=4;n++) { for (int k=1;k<=n;k++) {System.out.print(k);} System.out.println(); 4. Which one of the following is true for primitive data types? A. A String is an example of a primitive data type. B. Primitive data types cannot be passed as a parameter to a method. C. Primitive data types can be tested for equality using the '==' operator. D. Arrays can only store primitive data types 5. Which statement about 'do while' loops is true? A. A 'do-while' loop always executes at least one iteration. B. A do-while loop operates exactly the same as a 'while' loop except the 'while' statement is at the end. C. A do-while loop can never execute an iteration if the while condition is false. D. A 'do-while' loop will not terminate unless a 'break' statement is included. 6. Select the one correct statement about the code below. public class Test { public static void main(String[] args) { for (int i=0; i<10 ; i++) { int k = i * 3; } System.out.println(i); } } A. The program has a syntax error. B. The program compiles and displays 9 when executed. C. The program compiles and displays 10 when executed. D. The program compiles and displays 30 when executed. 7. Which statement about constructors is NOT true? A. The constructor can only be used with the 'new ' keyword. B. There can be many constructors for a class. C. If no constructor is defined, a default constructor is available. D. A constructor method definition returns void. 8. Which of the following statements about the toString()method is NOT correct? A. toString() prints out a description of its object.. B. toString() can be overloaded. C. toString() can be used to display an object as a String. D. toString() is automatically used by System.out.println() 9. What output does the following code produce? int m = 1, n = 2; System.out.println ("Java" + m + n); A. Javamn B. Javam+n C. Java12 D. Java3 10. What is the result of attempting to compile and run the program? class Question6 { public static void main(String[] args) { boolean b = true; if (b = false) { System.out.print("A"); } else if (b) { System.out.print("B"); } else { System.out.print("C"); } } } A. Prints: A B. Prints: B C. Prints: C D. Compile-time error #im a pre university student,since lockdown is happening classes got to cancel...couldnt study well.. but my lecturer has given us this,so kinda stuckk...need your guide,,tqvm
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started