More java quizzes

User Generated

UneelC

Programming

Description

6.

Which three are legal array declarations?

  1. int [] myScores [];
  2. char [] myChars;
  3. int [6] myScores;
  4. Dog myDogs [];
  5. Dog myDogs [7];
A.1, 2, 4
B.2, 4, 5
C.2, 3, 4
D.All are correct.


7.
public interface Foo 
{ 
    int k = 4; /* Line 3 */
}
Which three piece of codes are equivalent to line 3?
  1. final int k = 4;
  2. public int k = 4;
  3. static int k = 4;
  4. abstract int k = 4;
  5. volatile int k = 4;
  6. protected int k = 4;


8.

Which one of the following will declare an array and initialize it with five numbers?

A.Array a = new Array(5);
B.int [] a = {23,22,21,20,19};
C.int a [] = new int[5];
D.int [5] array;


9.

Which three are valid declarations of a char?

  1. char c1 = 064770;
  2. char c2 = 'face';
  3. char c3 = 0xbeef;
  4. char c4 = \u0022;
  5. char c5 = '\iface';
  6. char c6 = '\uface';


10.

Which is the valid declarations within an interface definition?

A.public double methoda();
B.public final double methoda();
C.static void methoda(double d1);
D.protected void methoda(double d1);

User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

Explanation & Answer

here is the work....

Which three are legal array declarations?
1.
2.
3.
4.
5.

int [] myScores [];
char [] myChars;
int [6] myScores;
Dog myDogs [];
Dog myDogs [7];

A.1, 2, 4
B. 2, 4, 5
C.2, 3, 4
D.All are ...


Anonymous
Great! 10/10 would recommend using Studypool to help you study.

Studypool
4.7
Trustpilot
4.5
Sitejabber
4.4

Related Tags