AP Computer Science A Unit 1 Exam With
Correct Solutions 2024
Assuming .that .scan .is .a .properly .initialized .Scanner .variable, .which .of .the .following
.correctly .inputs .a .String? .- .correct .answer.String .val .= .scan.nextLine();
Consider .the .following .code:
int .x .= .-3;
x--;
System.out.println(x);
What .is .output? .- .correct .answer.-4
Which .of .the .following .data .types .would .be .most .appropriate .to .use .when .recording
.whether .a .switch .is .in .the ."on" .or ."off" .position? .- .correct .answer.boolean
Which .of .the .following .is .NOT .a .primitive .data .type? .- .correct .answer.String
What .is .output .by .the .following .code?
int .a .= .91;
System.out.println(a ./ .2); .- .correct .answer.45
Which .of .the .following .is .a .legal .variable .name .in .Java? .- .correct .answer.ans
What .is .(6 .% .2) .* .7? .- .correct .answer.0
Which .of .the .following .would .properly .create .A .and .B .as .integer .variables? .- .correct
.answer.int .A;
int .B;
Which .of .the .following .correctly .stores .the .word .umbrella .in .a .variable .called .stuff? .-
.correct .answer.String .stuff .= ."umbrella";
Consider .the .following .code:
int .c .= .3 .- .37 .% .2; .
System.out.println(c);
What .is .output? .- .correct .answer.2
Correct Solutions 2024
Assuming .that .scan .is .a .properly .initialized .Scanner .variable, .which .of .the .following
.correctly .inputs .a .String? .- .correct .answer.String .val .= .scan.nextLine();
Consider .the .following .code:
int .x .= .-3;
x--;
System.out.println(x);
What .is .output? .- .correct .answer.-4
Which .of .the .following .data .types .would .be .most .appropriate .to .use .when .recording
.whether .a .switch .is .in .the ."on" .or ."off" .position? .- .correct .answer.boolean
Which .of .the .following .is .NOT .a .primitive .data .type? .- .correct .answer.String
What .is .output .by .the .following .code?
int .a .= .91;
System.out.println(a ./ .2); .- .correct .answer.45
Which .of .the .following .is .a .legal .variable .name .in .Java? .- .correct .answer.ans
What .is .(6 .% .2) .* .7? .- .correct .answer.0
Which .of .the .following .would .properly .create .A .and .B .as .integer .variables? .- .correct
.answer.int .A;
int .B;
Which .of .the .following .correctly .stores .the .word .umbrella .in .a .variable .called .stuff? .-
.correct .answer.String .stuff .= ."umbrella";
Consider .the .following .code:
int .c .= .3 .- .37 .% .2; .
System.out.println(c);
What .is .output? .- .correct .answer.2