0

programming languages Online Quiz - 141

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

1)main() { int i = 5; printf(“%d %d %d %d %d”,i++,i--,++i,--i,i); }

  1. 5 6 6 5 5

  2. 6 5 6 5 5

  3. 5 5 6 5 5

  4. 4 5 5 4 5


Correct Option: D

1)void main() { int const *p = 5; printf(“%d”,++(*p)); }

  1. 6

  2. junk value

  3. some address

  4. error


Correct Option: D

1)#define square(x) x*xmain(){ int i; i=64/square(4); printf(“%d”,i);}

  1. 32

  2. 4

  3. 64

  4. 16


Correct Option: C

1)main() { int a[2][3][2]={{{2,4},{7,8},{3,4}},{{2,2},{2,3},{3,4}}}; printf(“%u %u %u %d”,a,a,a,a); printf(“%u %u %u %d\n”,a+1,*a+1,a+1,***a+1); } Provided base address of a is 100.

  1. 100 100 100 2 112 104 102 3

  2. 100 104 108 3 112 116 120 3

  3. 100 100 100 2 112 104 102 2

  4. 100 104 108 2 112 116 120 2


Correct Option: A

1)main() { static int a[]={0,1,2,3,4}; int p[]={a,a+1,a+2,a+3,a+4}; int **ptr=p; ptr++; printf(“\n%d%d%d”ptr-p,*ptr-a,ptr); *ptr++; printf(“\n%d%d%d”ptr-p,*ptr-a,ptr); *++ptr; printf(“\n%d%d%d”ptr-p,*ptr-a,ptr); ++*ptr; printf(“\n%d%d%d”ptr-p,*ptr-a,*ptr); }

  1. 123 234 340 012

  2. 111 222 333 444

  3. 111 222 444 333

  4. 012 340 234 123


Correct Option: B

Which of the following statements are valid array declaration?

  1. int number();

  2. float average[];

  3. double[] marks;

  4. counter int[];


Correct Option: B,C

Which of the following classes are available in the java.lang package?

  1. Object

  2. Math

  3. Random

  4. Stack


Correct Option: A,B

Which of the following are the wrapper classes?

  1. Byte

  2. Integer

  3. Short

  4. String


Correct Option: A,B,C

Given the code String s1 = "yes"; String s2 = "yes"; String s3 = new String(s1); Which of the following would equate to true?

  1. s1 == s2

  2. s3 == s1

  3. s1.equals(s2)

  4. s3.equals(s1)


Correct Option: A,C,D

AI Explanation

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

Option A) s1 == s2 - This option is incorrect. The == operator compares the memory addresses of the objects, not their content. Although s1 and s2 have the same content, they are two different String objects with different memory addresses.

Option B) s3 == s1 - This option is incorrect. The new String object created by new String(s1) has a different memory address compared to s1. Therefore, s3 and s1 are not the same object.

Option C) s1.equals(s2) - This option is correct. The equals() method compares the content of the strings. Since s1 and s2 have the same content ("yes"), this expression will evaluate to true.

Option D) s3.equals(s1) - This option is correct. The equals() method compares the content of the strings. Although s3 and s1 are different objects, they have the same content ("yes"). Therefore, this expression will evaluate to true.

The correct answers are A, C, and D. These options are correct because they compare the content of the strings using either the == operator or the equals() method, which yields the expected result.

The methods wait() and notify() are defined in

  1. java.lang.Thread

  2. java.lang.Object

  3. java.lang.Runnable

  4. java.lang.ThreadGroup


Correct Option: B

virtual function defined in the parent class should be redefined in all of its inheriting child classes

  1. True

  2. False


Correct Option: B

string s="tcs". This is a valid c++ syntax.

  1. True

  2. False


Correct Option: A

Static global variable in one c++ file can be used in another c++ file with the help of extern keyword.

  1. True

  2. False


Correct Option: B

“abc” is a primitive value

  1. True

  2. False


Correct Option: B

A class is a subclass of itself.

  1. True

  2. False


Correct Option: A

Exceptions can be rethrown.

  1. True

  2. False


Correct Option: A

void is the return type of a program’s main() method

  1. True

  2. False


Correct Option: A

non-Unicode letter characters $ and _ cannot be used as the first character of an identifier

  1. True

  2. False


Correct Option: B

this() is used to invoke a constructor of the same class

  1. True

  2. False


Correct Option: A
- Hide questions