0

programming languages Online Quiz - 173

Description: programming languages Online Quiz - 173
Number of Questions: 20
Created by:
Tags: programming languages
Attempted 0/20 Correct 0 Score 0
  1. 0 false 0

  2. 0 true 0

  3. 0 0 0

  4. Compile error - static variable must be initialized before use.


Correct Option: A
Explanation:

To solve this question, the user needs to know about Java classes, instance variables, static variables, and method invocation.

The given program has two classes: A and Test. The A class defines three instance variables: k (of type int), istrue (of type boolean), and a static variable p (of type int). Class A also defines a method named printValue() that prints the values of k, istrue, and p, in that order.

In the main() method of the Test class, an object of class A is created and its printValue() method is called.

Since int and boolean instance variables are initialized to their default values of 0 and false respectively, and the static variable p is also initialized to 0, the output of the program will be:

A. 0 false 0

Option A is correct because the program will print the values of k (0), istrue (false), and p (0) in that order.

Option B is incorrect because istrue is initialized to false, not true.

Option C is incorrect because k and istrue are both non-static instance variables, and they will be initialized to their default values of 0 and false, respectively. The static variable p will also be initialized to 0.

Option D is incorrect because there is no compile error in the code.

The Answer is: A. 0 false 0

What is the output for the below code ? 1. public class Test { 2. public static void main(String... args) { 3. int [] index = new int[5]; 4. System.out.println(index instanceof Object); 5. } 6. }

  1. Compilation fails with an error at line 4

  2. Compilation fails with an error at line 3

  3. true

  4. false


Correct Option: C

AI Explanation

To answer this question, let's go through each option to understand why it is correct or incorrect:

Option A) Compilation fails with an error at line 4 - This option is incorrect. The code at line 4 is valid and will not cause a compilation error.

Option B) Compilation fails with an error at line 3 - This option is incorrect. The code at line 3 is valid and will not cause a compilation error.

Option C) true - This option is correct. The code at line 4 checks whether the variable "index" is an instance of the Object class. Since arrays in Java are objects, the expression "index instanceof Object" evaluates to true.

Option D) false - This option is incorrect. As mentioned earlier, arrays in Java are objects, so the expression "index instanceof Object" evaluates to true, not false.

The correct answer is C) true. This option is correct because the code will output "true" to the console.

If we do ArrayList lst = new ArrayList(); What is the initial capacity of the ArrayList lst ?

  1. 8

  2. 10

  3. none

  4. 0


Correct Option: B
  1. Map m = Collection.synchronizeMap(hashMap);

  2. Map m = Collections.synchronizeMap(hashMap);

  3. Map m = hashMap.synchronizeMap();

  4. none


Correct Option: B

What is the output for the below code ? 1. public class Test {2. int i=8; 3. int j=9; 4. public static void main(String[] args){ 5. add(); 6. } 7. public static void add(){ 8. int k = i+j; 9. System.out.println(k); 10. } 11. }

  1. Compilation fails with an error at line 5

  2. Compilation fails with an error at line 8

  3. 17

  4. 0


Correct Option: B

What does this program do ? public class BrowserTest { public static void main(String[] args) { System.out.print("iexplore:"); http://www.google.com; System.out.println(":maximize"); } }

  1. Compilation Error

  2. iexplore::maximize

  3. Runtime Error

  4. None of these


Correct Option: B

What does it print ? import java.util.*; public class NameGame { public static void main(String args[]) { Map m = new IdentityHashMap(); m.put("Mickey", "Mouse"); m.put("Mickey", "Mantle"); System.out.println(m.size()); } }

  1. Exception

  2. Stack Overflow

  3. 2

  4. 1


Correct Option: D
  1. EXE is created for the called program and DLL is created for the calling program

  2. EXE is created for the calling program and DLL is created for the called program

  3. EXE is created for the both, called program and calling program

  4. DLL is created for the both, called program and calling program


Correct Option: B

All M0 is not the part of core modules

  1. True

  2. False


Correct Option: A

Following are the main core modules

  1. HC9999M1WC3

  2. HC9999M1

  3. HC9999M2

  4. HC9999R0

  5. HC9999CD

  6. All of the above


Correct Option: F
  1. A File with .txt extension

  2. A File with .dat extension

  3. A File with .xml extension

  4. Tables in the SQL database

  5. All of these

  6. None of these


Correct Option: E

Main Output of a M0 program will be

  1. An Index File

  2. A Sequential File

  3. It creates tables in the database

  4. None of these


Correct Option: B

Main tasks of the M1 processing are

  1. Application of WC3 components

  2. Householding based Sorting

  3. Report Generation

  4. PDF generation


Correct Option: A,B

Main output of M1 program is

  1. CON File

  2. Invalid File

  3. Member-File

  4. Thincard feed

  5. K1DBloader File


Correct Option: C
- Hide questions