Java SE: Programming I
Quiz
•
Computers
•
Professional Development
•
Hard
Karla Morales
Used 15+ times
FREE Resource
Enhance your content in a minute
10 questions
Show all answers
1.
MULTIPLE SELECT QUESTION
45 sec • 1 pt
Given the code fragment:
public class ForTest {
public static void main(String[] args) { int[] array = {1, 2, 3};
for ( foo ) {
}
}
Which three code fragments, when replaced individually for foo, enables the program to
compile?
A. int i : array
B. int i = 0; i < 1;
C. ; ;
D. ; i < 1; i++
E. i = 0; i<1;
2.
MULTIPLE SELECT QUESTION
45 sec • 1 pt
Given
public class ComputeSum { public int x;
public int y; public int sum;
public ComputeSum (int nx, int ny) { x = nx; y =ny;
updateSum();
}
public void setX(int nx) { x = nx; updateSum();} public void setY(int ny) { x = ny;
updateSum();} void updateSum() { sum = x + y;}
}
This class needs to protect an invariant on the sum field.
Which three members must have the private access modifier to ensure that this invariant is
maintained?
A. The x field
B. The y field
C. The sum field
D. The setX ( ) method
E. The setY ( ) method
3.
MULTIPLE SELECT QUESTION
45 sec • 1 pt
A. 100210
B. Compilation fails due to an error in line n1
C. Compilation fails due to an error at line n2
D. Compilation fails due to an error at line n3
4.
MULTIPLE SELECT QUESTION
45 sec • 1 pt
Which two statements are true?
A. An abstract class can implement an interface.
B. An abstract class can be extended by an interface.
C. An interface CANNOT be extended by another interface.
D. An interface can be extended by an abstract class.
E. An abstract class can be extended by a concrete class.
5.
MULTIPLE SELECT QUESTION
45 sec • 1 pt
Given:
abstract class A1 {
public abstract void m1();
public void m2() { System.out.println("Green"); }
}
abstract class A2 extends A1 { public abstract void m3();
public void m1() { System.out.println("Cyan"); } public void m2()
{
System.out.println("Blue"); }
}
public class A3 extends A2 {
public void m1() { System.out.println("Yellow"); } public void m2()
{ System.out.println("Pink"); } public void m3() { System.out.println("Red"); }
public static void main(String[] args) {
A2 tp = new A3(); tp.m1();
tp.m2();
tp.m3();
}
}
What is the result?
A. Yellow Pink Red
B. Cyan Blue Red C.
C.Cyan Green Red D.
D.Compilation Fails
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
A. hEllOjAvA!
B. Hello java!
C. Out of limits hEllOjAvA!
D. Out of limits
7.
MULTIPLE SELECT QUESTION
45 sec • 1 pt
Given the code fragment:
int [][] array2d = new int[2][3]; System.out.println("Loading the data."); for ( int x = 0; x <
array2d.length; x++) { for ( int y = 0; y < array2d[0].length; y++) { System.out.println(" x =
" + x); System.out.println(" y = " + y);
// insert load statement here.
}
}
System.out.println("Modify the data. "); for ( int x = 0; x < array2d.length; x++) { for ( int y
= 0; y < array2d[0].length; y++) { System.out.println(" x = " + x); System.out.println(" y = "
+ y);
// insert modify statement here.
}
}
Which pair of load and modify statement should be inserted in the code? The load statement
should set the array's x row and y column value to the sum of x and y The modify statement
should modify the array's x row and y column value by multiplying it by 2
A. Load statement: array2d(x, y) = x + y;
Modify statement: array2d(x, y) = array2d(x, y) * 2
B. Load statement: array2d[x y] = x + y;
Modify statement: array2d[x y] = array2d[x y] * 2
C. Load statement: array2d[x, y] = x + y;
Modify statement: array2d[x, y] = array2d[x, y] * 2
D. Load statement: array2d[x][y] = x + y;
Modify statement: array2d[x][y] = array2d[x][y] * 2
E. Load statement: array2d[[x][y]] = x + y;
Modify statement: array2d[[x][y]] = array2d[[x][y]] * 2
Create a free account and access millions of resources
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?
Similar Resources on Wayground
10 questions
Tipos de Gráficos
Quiz
•
Professional Development
10 questions
quizizz
Quiz
•
Professional Development
15 questions
Technical Training
Quiz
•
Professional Development
15 questions
Google Nivel 1 7-9
Quiz
•
Professional Development
10 questions
PreTrainingClassesObjectsMethods
Quiz
•
Professional Development
13 questions
FH 6.2.1 MME 11.1-Detección de averías
Quiz
•
Professional Development
10 questions
DIAGNÓSTICO SISTEMAS DE INFORMACIÓN
Quiz
•
Professional Development
10 questions
Exam Prep 1
Quiz
•
Professional Development
Popular Resources on Wayground
20 questions
Halloween Trivia
Quiz
•
6th - 8th Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
15 questions
Order of Operations
Quiz
•
5th Grade
20 questions
Halloween
Quiz
•
5th Grade
16 questions
Halloween
Quiz
•
3rd Grade
12 questions
It's The Great Pumpkin Charlie Brown
Quiz
•
1st - 5th Grade
20 questions
Possessive Nouns
Quiz
•
5th Grade
10 questions
Halloween Traditions and Origins
Interactive video
•
5th - 10th Grade
Discover more resources for Computers
10 questions
Halloween
Quiz
•
Professional Development
16 questions
Spooky Season Quiz
Quiz
•
Professional Development
5 questions
11.4.25 Student Engagement & Discourse
Lesson
•
Professional Development
50 questions
ASL Colors and Clothes
Quiz
•
KG - Professional Dev...
15 questions
Ohms Law
Quiz
•
Professional Development
10 questions
Halloween Trivia
Quiz
•
Professional Development
10 questions
Halloween Trivia
Quiz
•
Professional Development
