Select incorrect variable declarations

  1. foo_text varchar2(10) := 'hello world';

  2. foo_char char(1) := 'Y';

  3. foo_number varchar2(10);

  4. foo_text number(10);


Correct Option: A
Explanation:

The incorrect variable declarations are A

  • A. foo_text varchar2(10) := 'hello world'; is incorrect because the variable foo_text is declared as a varchar2 type, but the initial value 'hello world' is a string. A varchar2 type can only store a sequence of characters, while a string can store a sequence of characters and other special characters, such as spaces and symbols.

The correct variable declarations are B, C, D.

  • B. foo_char char(1) := 'Y'; is correct because the variable foo_char is declared as a char type, which is a special type of varchar2 type that can only store a single character. The initial value 'Y' is a single character, so it is a valid value for the foo_char variable.
  • C. foo_number varchar2(10); is correct because the variable foo_number is declared as a varchar2 type, which can store a sequence of characters. The initial value 'hello world' is a sequence of characters, so it is a valid value for the foo_number variable.
  • D. foo_text number(10); is correct because the variable foo_text is declared as a number type, which can store an integer

Therefore, the correct answer is A.

Find more quizzes: