 ### programming languages Online Quiz - 223

 Description: programming languages Online Quiz - 223 Number of Questions: 20 Created by: Aliensbrain Bot Tags: programming languages
Attempted 0/20 Correct 0 Score 0

What are the two parts of a value of type double?

1. significant digits

2. length

3. numerator

4. denominator

Correct Option: A

After the following code fragment, what is the value in a?String s;int a;s = "Foolish boy.";a = s.indexOf("fool");

1. -1

2. 0

3. 4

4. 8

Correct Option: A

What is the value of k after the following code fragment? int k = 0; int n = 12 while (k < n) { k = k + 1; }

1. O

2. 11

3. 12

4. -3

Correct Option: C

Given the following code fragment:int A[];int i = 0;A = new int A;while (i < 4){A[i] = 10;i = i + 1;}

1. 0

2. 3

3. 10

4. UNKNOWN

Correct Option: C

Given the following statement:huey.setDouble(8.0*32.2+1.0);What must be the data type of huey?

1. DoubleField

2. TextField

3. IntField

4. double

Correct Option: A

#### AI Explanation

To determine the data type of the variable "huey" in the given statement, let's analyze the expression used as an argument for the "setDouble()" method:

8.0 * 32.2 + 1.0

This expression involves multiplication and addition operations. When performing these operations, the data type of the resulting value depends on the data types of the operands involved.

In this case, both 8.0 and 32.2 are decimal numbers (floating-point numbers) represented using the double data type. The multiplication and addition operations will preserve the double data type.

Therefore, the resulting value of the expression is a double. Since the "setDouble()" method is used, we can conclude that the data type of the variable "huey" must be a DoubleField, which is the data type that can store double values.

A. DoubleField

The method setLabel can be used with what type of Object?

1. DoubleField

2. int

3. TextField

4. String

Correct Option: A

A function is:

1. An entity that receives inputs and outputs

2. A way of storing values

3. A sequence of characters enclosed by quotes

4. A kind of computer

Correct Option: A

A signed data type has an equal number of non-zero positive and negative values available.TRUE/FALSE ?

1. True

2. False

Correct Option: A

#### AI Explanation

To answer this question, we need to understand the concept of signed data types.

In computer programming, a signed data type is a data type that can represent both positive and negative values. It uses a sign bit to indicate the sign of the value. The sign bit is typically the leftmost bit in the binary representation of the number.

For example, in a signed 8-bit data type, the range of values is from -128 to 127. The sign bit (the most significant bit) is 0 for positive numbers and 1 for negative numbers.

Now, let's consider the statement: "A signed data type has an equal number of non-zero positive and negative values available."

This statement is true. In a signed data type, the number of positive values is equal to the number of negative values. This is because the sign bit can represent one of two values (0 or 1), which determines whether the number is positive or negative.

Therefore, the correct answer is A) True.

class C1 { static interface I { static class C2 { } } public static void main(String a[]) { C1.I.C2 ob1=new C1.I.C2(); System.out.println("object created"); } } What is the result of attempting to compile and run the program?

1. prints object created

2. Compile time error

3. Runtime Excepion

4. None of the above

Correct Option: A

class C1 { static class C2 { static int i1; } public static void main(String a[]) { System.out.println(C1.C2.i1); } } What is the result of attempting to compile and run the program?

1. prints 0

2. Compile time error

3. Runtime exception

4. None of the above

Correct Option: A

Which declare a compilable abstract class? (Choose all that apply.)

1. A. public abstract class Canine { public Bark speak(); }

2. B. public abstract class Canine { public Bark speak() { } }

3. C. public class Canine { public abstract Bark speak(); }

4. D. public class Canine abstract { public abstract Bark speak(); }

Correct Option: B

Which are legal declarations?

1. short x [];

2. short [] y;

3. short  x2;

4. short z2 ;

5. short [] z [] [];

6. short [] y2 = ;

Correct Option: A,B,E

Which is true? (Choose all that apply. )

1. A. "X extends Y" is correct if and only if X is a class and Y is an interface

2. B. "X extends Y" is correct if and only if X is an interface and Y is a class

3. C. "X extends Y" is correct if X and Y are either both classes or both interfaces

4. D. "X extends Y" is correct for all combinations of X and Y being classes and/or interfaces

Correct Option: C

Given: 1. class Voop { 2. public static void main(String [] args) { 3. doStuff(1); 4. doStuff(1, 2); 5. } 6. // insert code here 7. } Which, inserted independently at line 6, will compile? (Choose all that apply.)

1. static void doStuff(int... doArgs) { }

2. static void doStuff (int [] doArgs) { }

3. static void doStuff(int doArgs...) { }

4. static void doStuff(int... doArgs, int y) { }

5. static void doStuff(int x, int... doArgs) { }

Correct Option: A,E

Given the following, 1. interface Base { 2. boolean m1 (); 3. byte m2(short s); 4. } Which code fragments will compile? (Choose all that apply.)

1. interface Base2 implements Base { }

2. abstract class Class2 extends Base { public boolean ml() { return true; } }

3. abstract class Class2 implements Base { }

4. abstract class Class2. implements Base { public boolean m1() { return (true); } }

5. class Class2 implements Base { boolean m1( ) { return false; } byte m2(short s) { return 42; } }

Correct Option: C,D

Which declare a compilable abstract class? (Choose all that apply.)

1. public abstract class Canine { public Bark speak(); }

2. public abstract class Canine { public Bark speak() { } }

3. public class Canine { public abstract Bark speak(); }

4. public class Canine abstract { public abstract Bark speak(); }

Correct Option: B

Which is true? (Choose all that apply. )

1. "X extends Y" is correct if and only if X is a class and Y is an interface.

2. "X extends Y" is correct if and only if X is an interface and Y is a class.

3. "X extends Y" is correct if X and Y are either both classes or both interfaces.

4. "X extends Y" is correct for all combinations of X and Y being classes and/or interfaces.

Correct Option: C

Given: 1. class Voop { 2. public static void main(String [] args) { 3. doStuff(1); 4. doStuff(1, 2); 5. } 6. // insert code here 7. } Which, inserted independently at line 6, will compile? (Choose all that apply.)

1. static void doStuff(int... doArgs) { }

2. static void doStuff (int [] doArgs) { }

3. static void doStuff(int doArgs...) { }

4. static void doStuff(int... doArgs, int y) { }

5. static void doStuff(int x, int... doArgs) { }

Correct Option: A,E

Which are legal declarations? (Choose all that apply. )

1. short x [];

2. short [] y;

3. short  x2;

4. short z2 ;

5. short [] z [] [];

6. short [] y2 = ;

Correct Option: A,B,E

Can there be multiple tag in tiles-defs.xml?

1. No

2. Yes

3. always present

4. None of the above

Correct Option: A
- Hide questions