Exam 1: Review of Java Fundamentals

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

Write a for-loop that will print all the positive integers from 100 down to 1,inclusive,one number per line.

(Short Answer)
4.8/5
(36)

In order to declare a named constant,the declaration must use which Java keyword?

(Multiple Choice)
4.7/5
(31)

Integer literals beginning with the digit 0 are interpreted to be in decimal notation.

(True/False)
4.9/5
(38)

If an int is added to a float,the result will be an int.

(True/False)
4.8/5
(33)

All classes extend which built-in class?

(Multiple Choice)
4.9/5
(28)

What will happen when you try to run a program that has a syntax error?

(Essay)
4.7/5
(30)

Which of the following loop headers will arrange for the loop body to execute exactly 10 times?

(Multiple Choice)
4.9/5
(31)

Which type of loop is guaranteed to execute its body at least once?

(Multiple Choice)
4.8/5
(36)

The Java expression (75 - 63)* 10 / 6 - 1 evaluates to 19.

(True/False)
4.8/5
(26)

A leap year occurs when the year number is divisible by 4.But there is a special case for years ending in 00: these must be divisible by 400 to be considered a leap year.Thus,1900 was not a leap year,but 2000 was.Write an if-statement that determines if the integer variable year represents a leap year.(Hint: use the % operator for taking remainders. )

(Essay)
4.8/5
(41)

What feature of Java transforms class objects into a sequence of bytes that may be used by another program?

(Multiple Choice)
4.9/5
(32)

Suppose c1 and c2 are objects of the class Circle.A Circle has a single data member,its radius.The Circle class has a default constructor (implemented correctly),but no other methods have been defined in the implementation of the Circle class.What will happen when we try to execute this code? Circle c1 = new Circle(12.0); Circle c2 = new Circle(12.0); Boolean same = (c1.equals(c2));

(Multiple Choice)
4.8/5
(37)

Suppose a String variable s is initialized to the value "inheritance".What value is returned by the call s.substring(2,5)?

(Multiple Choice)
4.8/5
(39)

Comments beginning with the characters // can extend for multiple lines until the compiler encounters \\.

(True/False)
4.8/5
(34)

Suppose x and y are int variables.Write a statement that declares the boolean variable between,and sets this variable equal to true if the value of y is between 0 and x,inclusive,and equal to false otherwise.(Assume that you don't know if x is positive or negative. )

(Short Answer)
4.8/5
(39)

The Java expression 9 / 5 + 9 % 5 equals ______.

(Multiple Choice)
4.9/5
(36)

What type of Java statement allows you to use classes contained in other packages?

(Multiple Choice)
4.8/5
(39)

Suppose c is a variable of type char.We want to know if c is a lowercase vowel letter (a/e/i/o/u).What is wrong with the following comparison? if (c == 'a' || 'e' || 'i' || 'o' || 'u')

(Essay)
4.7/5
(36)

Which access modifier,used when defining a method,indicates that only one such method is available for all instances of the class?

(Multiple Choice)
4.9/5
(36)

Suppose a is a one-dimensional array of double.Show how you would find the largest element of a using Java code.

(Essay)
4.9/5
(38)
Showing 41 - 60 of 60
close modal

Filters

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