Data Types Interview Questions


What kinds of data exist in COBOL?

Numeric, Alphabetic and Alpha-numeric

What is meant by data types in COBOL?

A data type defines the kind of data a variable can hold, such as numeric values, alphabetic characters, or alpha-numeric strings.

What are data types in COBOL?

There are five data types in COBOL, and those are -

  • Alphabetic
  • Alpha-numeric
  • Numeric
  • Sign
  • Decimal Point

Can JUSTIFIED be used for all the data types?

No. JUSTIFIED is applicable only on Alphabetic and alpha-numeric data types.

What is the use of the REDEFINES clause in COBOL, and how can it be used to share data between different data types?

REDEFINES defines a new variable for the existing variable, which means two variables share the same memory area.
It is a way to declare multiple variables for a single memory area in different ways based on the requirement.

How do you work with date and time values in COBOL, and what are the different data types and manipulation options available?

A variable can be declared as 9(8) with the format YYYYMMDD to hold the date value.
A variable can be declared as 9(6) with the format HHMMSS to hold the time value.

Alphabetic Data Type -

What is the significance of alphabetic data type?

An alphabetic data type is used to declare the variables for storing and processing alphabetic strings.

What is the minimum size of a alphabetic field we define in COBOL?

1 byte

What is the maximum size of a alphabetic field we define in COBOL?

255 bytes

Specify some rules of alphabetic data type?

  • It should not code with any other data type.
  • USAGE DISPLAY is applicable for alphabetic data types. If no USAGE clause is coded, DISPLAY is applied. i.e., 1 character = 1 byte.

What is the default alignment of alphabetic data type?

Left

Can we override the default alignment of alphabetic data type? If yes, how?

Yes. Using JUSTIFIED clause

Alpha-numeric Data Type -

What is the significance of alphanumeric data type?

An alpha-numeric data type is used to declare the variables for processing alphanumeric strings that are a combination of characters from "A" to "Z" or "a" to "z" characters or 0 to 9 numbers and other allowed special characters.

What is the minimum size of a alphanumeric field we define in COBOL?

1 byte

What is the maximum size of a alphanumeric field we define in COBOL?

255 bytes

Specify some rules of alphanumeric data type?

  • It should not code with any other data type.
  • USAGE DISPLAY is applicable for alphabetic data types. If no USAGE clause is coded, DISPLAY is applied. i.e., 1 character = 1 byte.

What is the default alignment of alphanumeric data type?

Left

Can we override the default alignment of alphanumeric data type? If yes, how?

Yes. Using JUSTIFIED clause

Numeric Data Type -

What is the significance of numeric data type?

Numeric data type is used to declare the variables to store and process the numbers or decimal values.

What is the minimum size of a numeric field we can define in COBOL?

1 byte

What is the maximum size of a numeric field that can be defined in COBOL?

18 bytes

Specify some rules of numeric data type?

  • The maximum length of the numeric data type is 18 digits in the PICTURE clause.
  • It can code with other data types, such as P(actual decimal point), S(sign), and V(virtual decimal point).
  • All USAGE clauses are applicable for numeric data types. The variable length is calculated based on the USAGE clause used during the declaration.
  • If no USAGE clause is coded, DISPLAY computation is applied to the declaration. i.e., i.e., 1 character = 1 byte.

What is the default alignment of numeric data type?

Right

Can we override the default alignment of numeric data type? If yes, how?

No. Not possible.

Decimal Point-Data Type -

What is the significance of decimal-point data type?

When an input is decimal, we should declare a variable with a decimal point to handle it. Decimal point data type declares only with the combination of numeric data type.

What is the real decimal point data type?

Dot | period (.) is used with the variable declaration to process the decimal value along with dot. The Dot is counted as part of the variable length.

What is the assumed decimal point data type?

"V" is used with a variable declaration to process the decimal value in arithmetic calculations. The "V" is not part of the data and does not count in the variable length.

What is the length of PIC 9.999?

5 bytes

What is Pic 9v99 Indicates?

3 bytes

If 123 value is moved to a PP999 PIC clause, then what is edited value taken?

000

Sign Data Type -

What is the significance of sign data type?

Sign data type is used to declare the numeric variable with the sign to capture the negative values. i.e., sign data type always comes up with numeric data type.

What is the significance of SIGN LEADING SEPARATE?

It specifies that the sign is stored as a separate character before the value.

What is the significance of SIGN TRAILING SEPARATE?

It specifies that the sign is stored as a separate character, after the value.

How many bytes does a S9(7) field occupy?

7 bytes

How many bytes does a S9(7) SIGN LEADING SEPARATE field occupy?

8 bytes

Frequently Asked Questions -

Different data types in COBOL?
What are the available data types in the COBOL language?
What are data types available in the COBOL language?
What are the three data types in COBOL?
Name the data types available in COBOL?
What are the different data types in COBOL?
What are the different data types available in COBOL?
What are the different data types that COBOL supports?
How many datatypes are there in COBOL?

Explain the differences between numeric, alpha numeric, and alphabetic data types in COBOL?

What is the use of JUSTIFIED clause in Alphabetic data type?

What is the use of JUSTIFIED clause in Alphanumeric data type?

What is the use of JUSTIFIED clause in numeric data type?

What is assumed decimal scaling position data type?

What is the difference between PIC 9.99 and PIC 9v99?

How many bytes does a S9(7) SIGN TRAILING SEPARATE field occupy?