Tag: programming languages

Questions Related to programming languages

SQL was developed by

  1. Donald D. Chamberlin and Raymond F. Boyce

  2. Donald D. Chamberlin

  3. Raymond F. Boyce

  4. none


Correct Option: A
  1. Modifying existing Data type.

  2. Used for defining type of data type used.

  3. Creating new data type names

  4. Not a valid key word


Correct Option: A

"typedefs" used for data types are not machine dependent.

  1. True

  2. False


Correct Option: B
  1. x = 4, y = 1, z = 5

  2. x = 3, y = 2, z = 6

  3. x = -7, y = 1, z = 5

  4. x = 4, y = 2, z = 6


Correct Option: B
Explanation:

To solve this question, the user needs to know the order of operations in C programming and the difference between pre-increment and post-increment operators.

First, let's break down the expression x = 0 - (++y) + z++:

  1. ++y is a pre-increment operator, which means it increments the value of y by 1 before the value is used in the expression. So, y becomes 2.
  2. z++ is a post-increment operator, which means it increments the value of z by 1 after the value is used in the expression. So, z remains 5 in this expression.
  3. The expression inside the parentheses is evaluated first, so ++y is evaluated to 2.
  4. Next, the multiplication and division are evaluated from left to right, but there are none in this expression.
  5. Finally, the addition and subtraction are evaluated from left to right.

So, 0 - (++y) evaluates to -2 and z++ evaluates to 5, therefore the whole expression evaluates to -2 + 5 = 3.

Therefore, the correct answer is:

The Answer is: B. x = 3, y = 2, z = 6

Given the declarations boolean b; short x1 = 100, x2 = 200, x3 = 300; Which of the following statements are evaluated to true? (A) b = x1 * 2 == x2; (B) b = x1 + x2 != 3 * x1; (C) b = (x3 - 2*x2<0) || ((x3 = 400)<2**x2); (D) b = (x3 - 2*x2>0) || ((x3 = 400) 2*x2);

  1. (A), (B) & (C)

  2. (A), (C) & (D)

  3. (B) & (C)

  4. (A) & (C)

  5. (A) & (D)


Correct Option: D

AI Explanation

To determine which of the following statements are evaluated to true, let's evaluate each statement one by one:

Option A) b = x1 * 2 == x2; In this statement, x1 is multiplied by 2 and then compared with x2 using the equality operator. If the result of the comparison is true, then b will be assigned the value true. Otherwise, it will be assigned the value false.

Option B) b = x1 + x2 != 3 * x1; In this statement, x1 is added to x2 and the result is compared with 3 times x1 using the inequality operator. If the result of the comparison is true, then b will be assigned the value true. Otherwise, it will be assigned the value false.

Option C) b = (x3 - 2*x2<0) || ((x3 = 400)<2*x2); In this statement, there are two parts to the expression separated by the logical OR operator (||). The first part (x3 - 2*x2<0) checks if x3 - 2*x2 is less than 0. The second part ((x3 = 400)<2*x2) assigns the value 400 to x3 and then checks if the result is less than 2 raised to the power of x2. If either part of the expression evaluates to true, then b will be assigned the value true.

Option D) b = (x3 - 2*x2>0) || ((x3 = 400) 2*x2); In this statement, there are two parts to the expression separated by the logical OR operator (||). The first part (x3 - 2*x2>0) checks if x3 - 2*x2 is greater than 0. The second part ((x3 = 400) 2*x2) assigns the value 400 to x3 and then multiplies it by 2*x2. If either part of the expression evaluates to true, then b will be assigned the value true.

Now, let's evaluate each option:

Option A) (A), (B) & (C) Option B) (A), (C) & (D) Option C) (B) & (C) Option D) (A) & (C) Option E) (A) & (D)

Based on the evaluation of each statement, the correct answer is D) (A) & (C).

Statement (A) is evaluated to false because x1 * 2 is not equal to x2. Statement (B) is evaluated to true because x1 + x2 is not equal to 3 times x1. Statement (C) is evaluated to true because the first part of the expression (x3 - 2*x2<0) is false, but the second part of the expression ((x3 = 400)<2**x2) is true after assigning 400 to x3. Statement (D) is evaluated to false because the first part of the expression (x3 - 2*x2>0) is false, and the second part of the expression ((x3 = 400) 2*x2) is not a valid expression.

Therefore, the correct answer is (A) & (C).

  1. (A), (B) & (C)

  2. (A), (C) & (E)

  3. (A), (C) & (D)

  4. (A) & (E)

  5. (C) & (E)


Correct Option: B
Explanation:

To answer this question, the user needs to have a basic understanding of flow control statements in programming. Flow control statements are used to control the order in which statements are executed in a program. They can be used to make decisions, loop over sets of instructions, and interrupt the normal flow of execution.

Now, let's go through each option and explain why it is right or wrong:

A. (A), (B) & (C): Option A is incorrect because (B) break(); is not a valid flow control statement. (A) break; is a legal statement that is used to terminate a loop or switch statement. (C) continue outer; is also a legal statement that is used to skip to the next iteration of an outer loop. Therefore, option A is incorrect.

B. (A), (C) & (E): Option B is correct. (A) break; is a legal statement that is used to terminate a loop or switch statement. (C) continue outer; is also a legal statement that is used to skip to the next iteration of an outer loop. (E) return; is a legal statement that is used to exit a function and return a value. Therefore, option B is the correct answer.

C. (A), (C) & (D): Option C is incorrect because (D) continue(inner); is not a valid flow control statement. (A) break; is a legal statement that is used to terminate a loop or switch statement. (C) continue outer; is also a legal statement that is used to skip to the next iteration of an outer loop. Therefore, option C is incorrect.

D. (A) & (E): Option D is incorrect because (E) exit(); is not a valid flow control statement. (A) break; is a legal statement that is used to terminate a loop or switch statement. (E) return; is also a legal statement that is used to exit a function and return a value. Therefore, option D is incorrect.

E. (C) & (E): Option E is incorrect because it is missing a legal statement. (C) continue outer; is a legal statement that is used to skip to the next iteration of an outer loop. (E) return; is also a legal statement that is used to exit a function and return a value. Therefore, option E is incorrect.

The Answer is: B. (A), (C) & (E)

Given: • d is a valid, non-null Date object • df is a valid, non-null DateFormat object set to the current locale What outputs the current locales country name and the appropriate version of d’s date?

  1. Locale loc = Locale.getLocale();System.out.println(loc.getDisplayCountry()+ “ “+ df.format(d));

  2. Locale loc = Locale.getDefault();System.out.println(loc.getDisplayCountry()+ “ “ + df.format(d));

  3. Locale bc = Locale.getLocale();System.out.println(loc.getDisplayCountry()+ “ “+ df.setDateFormat(d));

  4. Locale loc = Locale.getDefault();System.out.println(loc.getDispbayCountry()+ “ “+ df.setDateFormat(d));


Correct Option: B

AI Explanation

To answer this question, we need to understand how to obtain the current locale and display the country name along with the appropriate version of a Date object.

Option A) Locale loc = Locale.getLocale();System.out.println(loc.getDisplayCountry()+ “ “+ df.format(d)); This option is incorrect because the method getLocale() is not a valid method to obtain the current locale. Additionally, the method getDisplayCountry() is used to get the display name of the country for the specified locale and not the current locale.

Option B) Locale loc = Locale.getDefault();System.out.println(loc.getDisplayCountry()+ “ “ + df.format(d)); This option is correct. The method getDefault() is used to obtain the current locale. The getDisplayCountry() method is used to get the display name of the country for the specified locale, which in this case is the current locale. The df.format(d) formats the date object d using the DateFormat object df.

Option C) Locale bc = Locale.getLocale();System.out.println(loc.getDisplayCountry()+ “ “+ df.setDateFormat(d)); This option is incorrect because the method getLocale() is not a valid method to obtain the current locale. Additionally, the setDateFormat(d) is not a valid method for the DateFormat object. The correct method for formatting a date object is format(d).

Option D) Locale loc = Locale.getDefault();System.out.println(loc.getDispbayCountry()+ “ “+ df.setDateFormat(d)); This option is incorrect because the method getDispbayCountry() is not a valid method. The correct method to obtain the display name of the country is getDisplayCountry().

The correct answer is B) Locale loc = Locale.getDefault();System.out.println(loc.getDisplayCountry()+ “ “ + df.format(d)). This option correctly obtains the current locale and displays the country name along with the appropriate version of the date object.

What is an Iterator ?

  1. Enables you to cycle through a collection in the forward direction only, for obtaining or removing elements

  2. just for loop

  3. while loop

  4. It is an class for storing objects


Correct Option: A