Test: Computer Science


What is the error in the following code?

int val1 = -14,val2 = 4;

final int val3 = 9;

double val4 = 4.1;

double val5 = 3.1;

val1 = val2 * val3;

val3 = val1 * 12;

val5 = val1 - val3;

val4 = val2 + val5;

You cannot assign the result of an integer subtraction to val5.

You must define val2 on its own line.

You cannot perform mixed addition or subtraction with doubles and integers.

You cannot multiply val3 by val2.

You cannot assign the new integer value to val3.

1/2 questions


Access results and powerful study features!

Take 15 seconds to create an account.
Start now! Create your free account and get access to features like:
  • Full length diagnostic tests
  • Invite your friends
  • Access hundreds of practice tests
  • Monitor your progress over time
  • Manage your tests and results
  • Monitor the progress of your class & students
By clicking Create Account you agree that you are at least 13 years old and you agree to the Varsity Tutors LLC Terms of Use and Privacy Policy.
Learning Tools by Varsity Tutors