Tag: programming languages

Questions Related to programming languages

  1. List Programming

  2. LISt Programming

  3. List Instruction Set Programming

  4. List Information Set Programming


Correct Option: B
  1. Common Object Business Oriented Language

  2. Complete Object Business Oriented Language

  3. Common Object BASIC Oriented Language

  4. Common Oriented Business Object Language


Correct Option: A
  1. FORmula TRANslation

  2. FORmula TRANslator

  3. FORmal TRANslation

  4. FORmal TRANslator


Correct Option: B

Expansion of BASIC ......

  1. Begin All Program Symbolic Instruction Code

  2. Beginners' All-purpose Symbolic Information Code

  3. Beginners' All-purpose System Instruction Code

  4. Beginners' All-purpose Symbolic Instruction Code


Correct Option: D

You have the following code in a file called Test.java class Base{ public static void main(String[] args){ System.out.println("Hello"); } } public class Test extends Base{} What will happen if you try to compile and run this?

  1. It will fail to compile.

  2. Runtime error

  3. Compiles and runs with no output.

  4. Compiles and runs printing "Hello"


Correct Option: D

What is the result of trying to compile and run the following code. public final static void main(String[] args){ double d = 10.0 / -0; if(d == Double.POSITIVE_INFINITY) System.out.println("Positive infinity"); else System.out.println("Negative infinity"); }

  1. output Positive infinity

  2. output Negative infinity

  3. Will fail to compile

  4. Runtime exception


Correct Option: A

What is the result that will be printed out ? void aMethod() { float f = (1 / 4) * 10; int i = Math.round(f); System.out.println(i); }

  1. 2

  2. 0

  3. 3

  4. 2.5

  5. 25


Correct Option: B

AI Explanation

To determine the result that will be printed out, let's go through the code step by step:

  1. The expression (1 / 4) is evaluated. Since both 1 and 4 are integers, integer division is performed. In integer division, the result is the quotient without any remainder. So, 1 / 4 will evaluate to 0.

  2. The expression 0 * 10 is evaluated. Multiplying any number by 0 will always result in 0.

  3. The variable f is assigned the value of 0.

  4. The Math.round() function is called with f as the argument. The Math.round() function rounds the floating-point value to the nearest integer. In this case, since f is 0, it remains unchanged.

  5. The value of i is assigned the rounded value of f, which is still 0.

  6. Finally, the value of i is printed using System.out.println(i). So, the output will be 0.

Therefore, the correct answer is B) 0.

Which of the following are valid declarations?

  1. int i = 0XCAFE;

  2. boolean b = 0;

  3. char c = A;

  4. byte b = 128;

  5. char c = "A";


Correct Option: A

AI Explanation

To determine which of the given options are valid declarations, let's analyze each option:

A. int i = 0XCAFE; This option is a valid declaration. In Java, the prefix "0X" indicates a hexadecimal value. The hexadecimal value 0XCAFE is a valid integer value.

B. boolean b = 0; This option is not a valid declaration. In Java, the boolean data type can only have two possible values: true or false. Assigning an integer value of 0 to a boolean variable is not allowed.

C. char c = A; This option is not a valid declaration. In Java, character literals should be enclosed in single quotes (''). The character literal 'A' represents the character 'A', so the correct declaration would be char c = 'A';.

D. byte b = 128; This option is not a valid declaration. In Java, the byte data type can hold values from -128 to 127. Assigning the value 128 to a byte variable exceeds the range of valid values.

E. char c = "A"; This option is not a valid declaration. In Java, character literals should be enclosed in single quotes (''). The double quotes ("") are used for string literals. To assign the character 'A' to a char variable, the correct declaration would be char c = 'A';.

Therefore, the valid declaration among the given options is A) int i = 0XCAFE.