0

programming languages Online Quiz - 40

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

There are 4 divisions in a cobol program. Which of the following is not one of them?

  1. Identification Division

  2. Linkage Division

  3. Data Division

  4. Procedure Division


Correct Option: B

Cobol is self-documenting.

  1. True

  2. False


Correct Option: A

User defined names must follow which one of the following rules?

  1. Multiple word names must be separated with an underscore

  2. Names must be 10 or less characters

  3. Names must contain at least 1 alpha character in any position.

  4. Names must be lower case


Correct Option: C

Cobol paragraphs contain sentences. A sentence must end in a period and can contain multiple statements.

  1. True

  2. False


Correct Option: A

Sentences and statements must start on a new line.

  1. True

  2. False


Correct Option: B

When defining a file layout it is placed in the file section of the data division. Each record begins with an "01", a space, and the record name. Fields within a record traditionally began with 05?

  1. All of these answers.

  2. This is an alternate name for the 05 name.

  3. This is a breakdown of the 05 field.

  4. This is another format for the field.


Correct Option: C

Condition names are names associated with a field that take on a true/false status depending on whether their value is equal to the field value. They are indicated by a level number of what?

  1. 05

  2. 66

  3. 88

  4. 77


Correct Option: C

If a field is defined as Pic s9(6)v99 comp-3, it uses 5 bytes of storage.

  1. True

  2. False


Correct Option: B

AI Explanation

To answer this question, we need to understand the storage format of the PIC s9(6)v99 comp-3 data type.

The PIC s9(6)v99 comp-3 data type is a packed decimal representation. Packed decimal uses a specific encoding scheme to store decimal numbers in a compact manner.

In the given data type, s9(6)v99 represents a signed decimal number with 6 digits to the left of the decimal point and 2 digits to the right of the decimal point.

In the comp-3 format, each digit is stored in half a byte (4 bits), with the last half-byte reserved for the sign. The sign half-byte uses the following encoding scheme:

  • Positive sign (+) is represented by the value 0x0C.
  • Negative sign (-) is represented by the value 0x0D.

Therefore, each digit requires 4 bits of storage, and the sign requires an additional half-byte (4 bits).

For the given data type PIC s9(6)v99 comp-3, we have:

  • 6 digits to the left of the decimal point, requiring 6 * 4 = 24 bits or 3 bytes.
  • 2 digits to the right of the decimal point, requiring 2 * 4 = 8 bits or 1 byte.
  • 1 half-byte for the sign.

So, the total storage required for the PIC s9(6)v99 comp-3 data type is 3 bytes + 1 byte + 0.5 byte = 4.5 bytes.

Therefore, the statement "If a field is defined as Pic s9(6)v99 comp-3, it uses 5 bytes of storage" is incorrect.

The correct answer is B) False.

If we are limited to 5 bytes of storage, is there be a way to store a complete 8 digit date?

  1. True

  2. False


Correct Option: B

You store it as YYYYMMDD in 8 bytes. What is the COBOL definition of this field?

  1. Pic Y(4)M(2)D(2)

  2. Pic date(yyyymmdd)

  3. Pic date(8)

  4. Pic X(8)


Correct Option: D

class PrintTest{ public static void main(String[] args) { double d=222.4578; System.out.printf(“% .2f”,d); } }

  1. Does not compile

  2. Throws IllegalFormatConversionException

  3. Prints 222.46

  4. Prints 222.45


Correct Option: C

What is the result of compiling and running the following code, assuming that the file bb.txt does not exist? class WriterTest{ public static void main(String[] args) throws IOException{ Writer w=new BufferedWriter(new FileWriter(“bb.txt”)); // Line1 w.write(1); // Line2 w.close(); } }

  1. Compiler error

  2. FileNotFoundException thrown at line 1

  3. IOException thrown at line 2

  4. None of these


Correct Option: D

AI Explanation

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

Option A) Compiler error - This option is incorrect because there is no compiler error in the given code. The code compiles successfully.

Option B) FileNotFoundException thrown at line 1 - This option is incorrect because the FileNotFoundException is not thrown at line 1. The code attempts to create a new file "bb.txt" if it does not exist.

Option C) IOException thrown at line 2 - This option is incorrect because the IOException is not thrown at line 2. The code successfully writes the integer value "1" to the file.

Option D) None of these - This option is correct because there is no compiler error, FileNotFoundException, or IOException thrown in the given code. The code compiles successfully, creates a new file "bb.txt" if it does not exist, and writes the integer value "1" to the file before closing it.

The correct answer is D. None of these.

Which of the following statements are true about the default implementation of the public int hashCode() method of the Object class?

  1. The Object class does not provide any implementation for the hashCode method; every class must override it

  2. As far as it may be practically possible, the hashCode method defined by the Object class does return distinct integers for distinct objects

  3. For two object references referring to the same object, the hashCode method returns the same integer

  4. It returns a fixed number that internally represents the Object class for the JVM

  5. Only choice D is correct


Correct Option: B

whether the casting of objects can be done in java?

  1. True

  2. False


Correct Option: A

Read the code below. Will be the result of attempting to compile and run the code below. public class AQuestion { public void method(Object o){ System.out.println("Object Verion"); } public void method(String s){ System.out.println("String Version"); } public static void main(String args[]){ AQuestion question = new AQuestion(); question.method(null); } }

  1. The code does not compile

  2. The code compiles cleanly and shows “Object Version

  3. The code compiles cleanly and shows “String Version”

  4. The code throws an Exception at Runtime


Correct Option: C

Nohup command?

  1. kill the process

  2. To run the process even you shutdown the terminal

  3. display your terminal

  4. help command


Correct Option: B

cp command ?

  1. copies a file

  2. delete a file

  3. rename a file

  4. move a file


Correct Option: A

Grep Command ?

  1. compares two directories

  2. compares the two files

  3. To search one or more files to match an expression

  4. To make links to existing files


Correct Option: C

uniq command removes duplicate adjacent lines from sorted file?

  1. True

  2. False


Correct Option: A

awk command?

  1. to change ownership of a file or directory

  2. used to schedule jobs

  3. stream line editor

  4. scripting language builtin on all unix systems


Correct Option: D
- Hide questions