0

Jai solanki

Description: Ssc
Number of Questions: 37
Created by:
Tags: Ch 1
Attempted 0/37 Correct 0 Score 0

Overriding and Overloading is for ?

  1. Methods and variables

  2. class

  3. variables

  4. Methods


Correct Option: D

Overriding and Overloading is for ?

  1. Methods and variables

  2. class

  3. variables

  4. Methods


Correct Option: D
  1. class, if, void, long, Int, continue

  2. goto, instanceof, native, finally, default, throws

  3. try, virtual, throw, final, volatile, transient

  4. strictfp, constant, super, implements, do


Correct Option: B
Explanation:

All the words in option B are among the 49 Java keywords. Although goto reserved as a keyword in Java, goto is not used and has no function.Option A is wrong because the keyword for the primitive int starts with a lowercase i.Option C is wrong because "vi

  1. class, if, void, long, Int, continue

  2. goto, instanceof, native, finally, default, throws

  3. try, virtual, throw, final, volatile, transient

  4. strictfp, constant, super, implements, do


Correct Option: B
Explanation:

All the words in option B are among the 49 Java keywords. Although goto reserved as a keyword in Java, goto is not used and has no function.Option A is wrong because the keyword for the primitive int starts with a lowercase i.Option C is wrong because "vi

Which will legally declare, construct, and initialize an array?

  1. int [] myList = {"1", "2", "3"};

  2. int [] myList = (5, 8, 2);

  3. int myList [] [] = {4,9,7,0};

  4. int myList [] = {4, 3, 7};


Correct Option: D

Which will legally declare, construct, and initialize an array?

  1. int [] myList = {"1", "2", "3"};

  2. int [] myList = (5, 8, 2);

  3. int myList [] [] = {4,9,7,0};

  4. int myList [] = {4, 3, 7};


Correct Option: D
  1. method

  2. native

  3. subclasses

  4. reference


Correct Option: B
  1. method

  2. native

  3. subclasses

  4. reference


Correct Option: B
  1. interface

  2. string

  3. Float

  4. unsigned


Correct Option: A
  1. interface

  2. string

  3. Float

  4. unsigned


Correct Option: A

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

  1. Array a = new Array(5);

  2. int [] a = {23,22,21,20,19};

  3. int a [] = new int[5];

  4. int [5] array;


Correct Option: B

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

  1. Array a = new Array(5);

  2. int [] a = {23,22,21,20,19};

  3. int a [] = new int[5];

  4. int [5] array;


Correct Option: B

Which is the valid declarations within an interface definition?

  1. public double methoda();

  2. public final double methoda();

  3. static void methoda(double d1);

  4. protected void methoda(double d1);


Correct Option: A

Which is the valid declarations within an interface definition?

  1. public double methoda();

  2. public final double methoda();

  3. static void methoda(double d1);

  4. protected void methoda(double d1);


Correct Option: A
  1. boolean b1 = 0;

  2. boolean b2 = 'false';

  3. boolean b3 = false;

  4. boolean b4 = Boolean.false();


Correct Option: C
Explanation:

A boolean can only be assigned the literal true or false.

  1. boolean b1 = 0;

  2. boolean b2 = 'false';

  3. boolean b3 = false;

  4. boolean b4 = Boolean.false();


Correct Option: C
Explanation:

A boolean can only be assigned the literal true or false.

  1. boolean b1 = 0;

  2. boolean b2 = 'false';

  3. boolean b3 = false;

  4. boolean b4 = Boolean.false();


Correct Option: C
Explanation:

A boolean can only be assigned the literal true or false.

Which is a valid declarations of a String?

  1. String s1 = null;

  2. String s2 = 'null';

  3. String s3 = (String) 'abc';

  4. String s4 = (String) '\ufeed';


Correct Option: A

Which is a valid declarations of a String?

  1. String s1 = null;

  2. String s2 = 'null';

  3. String s3 = (String) 'abc';

  4. String s4 = (String) '\ufeed';


Correct Option: A

Which is a valid declarations of a String?

  1. String s1 = null;

  2. String s2 = 'null';

  3. String s3 = (String) 'abc';

  4. String s4 = (String) '\ufeed';


Correct Option: A

Which is a valid declarations of a String?

  1. String s1 = null;

  2. String s2 = 'null';

  3. String s3 = (String) 'abc';

  4. String s4 = (String) '\ufeed';


Correct Option: A

Which is a valid declarations of a String?

  1. String s1 = null;

  2. String s2 = 'null';

  3. String s3 = (String) 'abc';

  4. String s4 = (String) '\ufeed';


Correct Option: A
  1. -128 to 127

  2. -(215) to (215) - 1

  3. 0 to 32767

  4. 0 to 65535


Correct Option: D
  1. -128 to 127

  2. -(215) to (215) - 1

  3. 0 to 32767

  4. 0 to 65535


Correct Option: D
  1. -128 to 127

  2. -(215) to (215) - 1

  3. 0 to 32767

  4. 0 to 65535


Correct Option: D
  1. -128 to 127

  2. -(215) to (215) - 1

  3. 0 to 32767

  4. 0 to 65535


Correct Option: D

You want subclasses in any package to have access to members of a superclass. Which is the most restrictive access that accomplishes this objective?

  1. public

  2. protected

  3. private

  4. transient


Correct Option: B
Explanation:

protected makes a member accessible only to classes in the same package or subclass of the class

You want subclasses in any package to have access to members of a superclass. Which is the most restrictive access that accomplishes this objective?

  1. public

  2. protected

  3. private

  4. transient


Correct Option: B
Explanation:

protected makes a member accessible only to classes in the same package or subclass of the class

What is the most restrictive access modifier that will allow members of one class to have access to members of another class in the same package?

  1. public

  2. abstract

  3. protected

  4. synchronized

  5. default access


Correct Option: E
Explanation:

default access is the "package oriented" access modifier.

Which cause a compiler error?

  1. int[ ] scores = {3, 5, 7};

  2. int [ ][ ] scores = {2,7,6}, {9,3,45};

  3. String cats[ ] = {"Fluffy", "Spot", "Zeus"};

  4. boolean results[ ] = new boolean [] {true, false, true};


Correct Option: B

You want a class to have access to members of another class in the same package. Which is the most restrictive access that accomplishes this objective?

  1. public

  2. private

  3. protected

  4. default access


Correct Option: D

Which one creates an instance of an array?

  1. int[ ] ia = new int[15];

  2. float fa = new float[20];

  3. char[ ] ca = "Some String";

  4. int ia[ ] [ ] = { 4, 5, 6 }, { 1,2,3 };


Correct Option: A

Which of the following class level (nonlocal) variable declarations will not compile?

  1. protected int a;

  2. transient int b = 3;

  3. private synchronized int e;

  4. volatile int d;


Correct Option: C

AI Explanation

To answer this question, we need to understand the rules and restrictions for declaring class-level (nonlocal) variables in Java.

Let's go through each option to understand why it is correct or incorrect:

Option A) protected int a; This option is correct because there are no syntax errors or restrictions with declaring a protected class-level variable in Java.

Option B) transient int b = 3; This option is correct because there are no syntax errors or restrictions with declaring a transient class-level variable in Java.

Option C) private synchronized int e; This option is incorrect because it violates the rules for declaring class-level variables. In Java, the synchronized modifier is not allowed for class-level variables. It can only be used for instance-level methods or blocks.

Option D) volatile int d; This option is correct because there are no syntax errors or restrictions with declaring a volatile class-level variable in Java.

Therefore, the correct answer is C) private synchronized int e. This option will not compile because the synchronized modifier is not allowed for class-level variables in Java.

Please select the most appropriate option.

Given a method in a protected class, what access modifier do you use to restrict access to that method to only the other members of the same class?

  1. final

  2. static

  3. private

  4. protected


Correct Option: C
Explanation:

The private access modifier limits access to members of the same class.

Which is a valid declaration within an interface?

  1. public static short stop = 23;

  2. protected short stop = 23;

  3. transient short stop = 23;

  4. final void madness(short stop);


Correct Option: A

AI Explanation

To answer this question, you need to understand the rules for declaring variables and methods within an interface. Let's go through each option to understand why it is correct or incorrect:

Option A) public static short stop = 23; - This option is correct. In an interface, you can declare variables with the "public static" modifiers. The variable "stop" is declared as a public static short and assigned the value 23.

Option B) protected short stop = 23; - This option is incorrect. In an interface, variables cannot have access modifiers like "protected" or "private". They are implicitly public and static.

Option C) transient short stop = 23; - This option is incorrect. In an interface, variables cannot have modifiers like "transient". They can only have "public" and "static" modifiers.

Option D) final void madness(short stop); - This option is incorrect. In an interface, you can only declare method signatures, not method implementations. The "void" return type and the presence of the method body make this option invalid.

The correct answer is Option A) public static short stop = 23;. This option is correct because it follows the rules for declaring variables within an interface.

Therefore, the correct answer is A) public static short stop = 23;

Suppose that you would like to create an instance of a new Map that has an iteration order that is the same as the iteration order of an existing instance of a Map. Which concrete implementation of the Map interface should be used for the new instance?

  1. TreeMap

  2. HashMap

  3. LinkedHashMap

  4. The answer depends on the implementation of the existing instance.


Correct Option: C
  1. java.lang.String

  2. java.lang.Double

  3. java.lang.StringBuffer

  4. java.lang.Character


Correct Option: C
- Hide questions