Exam 1: Review of Java Fundamentals

arrow
  • Select Tags
search iconSearch Question
flashcardsStudy Flashcards
  • Select Tags

If x is a variable of type int,what is the largest possible value of the expression (x % 5)?

Free
(Multiple Choice)
4.9/5
(34)
Correct Answer:
Verified

B

If s = "hello,world" (with exactly one space between the comma and 'w'),what does s.indexOf(",")return?

Free
(Short Answer)
4.8/5
(35)
Correct Answer:
Verified

5

A statement invoking a constructor should also use the Java keyword ______.

Free
(Multiple Choice)
4.8/5
(36)
Correct Answer:
Verified

D

What does it mean for the return type of a method to be void?

(Multiple Choice)
4.7/5
(38)

Short-circuit evaluation refers to:

(Multiple Choice)
4.8/5
(35)

All Java classes must contain a method called main.

(True/False)
4.9/5
(38)

Which of these expressions is illegal in Java?

(Multiple Choice)
4.9/5
(33)

What is wrong with this loop? How would you fix it? int num = 1; while (num <= 10){ System.out.println("num = " + num); }

(Essay)
4.8/5
(34)

If d is a double and i is an int,then the assignment statement d = i;is legal in Java.

(True/False)
4.7/5
(34)

Which is not a primitive type in Java?

(Multiple Choice)
5.0/5
(34)

What is the meaning of the declaration: String [][] a = new String [60][80];?

(Multiple Choice)
4.8/5
(35)

When using the method System.out.printf( ),what is the purpose of the %d format code?

(Multiple Choice)
4.8/5
(39)

The following code attempts to find the sum of the elements in the third column (from the left)of a two dimensional int array called a that has 10 rows and 20 columns.Correct the errors in the code. int sum = 0; for (int i = 0;i < 20;i++) sum = sum + a[3][i];

(Essay)
4.7/5
(38)

In Java,when we write an if-statement of the form if(condition),the condition must evaluate to a boolean value.

(True/False)
4.8/5
(45)

If s1 = "dog" and s2 = "cat",then s1.compareTo(s2)returns a positive integer value.

(True/False)
4.8/5
(38)

Suppose a,b and c are the lengths of the 3 sides of a triangle.Write an if-statement that will determine if the triangle is isosceles (at least 2 of the 3 sides are equal).You may assume that a,b and c are of type int.

(Essay)
4.7/5
(44)

Why does the Java statement System.out.println("answer = " + 3 + 4); not print answer = 7 ?

(Essay)
4.9/5
(44)

How many constructors can a class have?

(Multiple Choice)
4.9/5
(45)

All Java programs must define at least one class.

(True/False)
4.7/5
(25)

Suppose s1 is a String variable.We want to check to see if the first and last characters of s1 are the same.Complete the following if-statement to accomplish the task. boolean same; if (______________________________________________) same = true; else same = false;

(Short Answer)
4.9/5
(44)
Showing 1 - 20 of 60
close modal

Filters

  • Essay(0)
  • Multiple Choice(0)
  • Short Answer(0)
  • True False(0)
  • Matching(0)