Explore topic-wise MCQs in General Awareness.

This section includes 1698 Mcqs, each offering curated multiple-choice questions to sharpen your General Awareness knowledge and support exam preparation. Choose a topic below to get started.

901.

+=, ?=, *=, /=, %= all are example of

A. Comparison operator
B. Assignment operator
C. Increment operator
D. Decrement operator
Answer» C. Increment operator
902.

Which operator returns true if two arguments are not equal or not have same type?

A. ===
B. ???
C. !==
D. +++
Answer» D. +++
903.

In multiple inheritance, if class C inherits two classes A and B as follows, which class constructor will be called first: class A{ }; class B{ }; class C: public A, public B{ };

A. A()
B. B()
C. C()
D. Can t be determined
Answer» B. B()
904.

It s necessary to pass object by reference in copy constructor because:

A. Constructor is not called in pass by reference
B. Constructor is called in pass by reference only
C. It passes the address of new constructor to be created
D. It passes the address of new object to be created
Answer» B. Constructor is called in pass by reference only
905.

Which among the following is correct, based on the given code below: class student { int marks; public : student() { cout<

A. Cout can t be used inside the constructor
B. Constructor must contain only initializations
C. This program works fine
D. This program produces errors
Answer» D. This program produces errors
906.

Which object will be created first? class student { int marks; }; student s1, s2, s3;

A. S1 then s2 then s3
B. S3 then s2 then s1
C. S2 then s3 then s1
D. All are created at same time
Answer» B. S3 then s2 then s1
907.

Which among the following is correct for the class defined below? class student { int marks; public: student(){} student(int x) { marks=x; } }; main() { student s1(100); student s2(); student s3=100; return 0;

A. Object s3, syntax error
B. Only object s1 and s2 will be created
C. Program runs and all objects are created
D. Program will give compile time error
Answer» D. Program will give compile time error
908.

Choose the correct option for the following code. class student { int marks; } student s1; student s2=2;

A. Object s1 should be passed with argument.
B. Object s2 should not be declared
C. Object s2 will not be created, but program runs
D. Program gives compile time error
Answer» E.
909.

What will be the output of the program? extern int var; int main(void) { var = 10; var++; cout<

A. 10
B. 11
C. Run time error
D. Compile time error
Answer» E.
910.

What is output of following code? package pack1; class A { public A() { System.out.print( object created ); } } package pack2; import pack1.*; class B { A a=new A(); }

A. Output is: object created
B. Output is: object createdobject created
C. Compile time error
D. Run time error
Answer» D. Run time error
911.

What will be the output of following code (all header files and required things are included)? class A { int marks; protected : A(int x) { marks=x; } public : A() { marks=100; } } class B { A a; A b=100; }; main() { A a, b=100; B c; }

A. Program runs fine
B. Program gives runtime error
C. Program gives compile time error
D. Program gives logical error
Answer» D. Program gives logical error
912.

Which among the following is true for the given code below. class A { protected : int marks; public : A() { marks=100; } disp() { cout<< marks= <<marks; } }; class B: protected A { }; B b; b.disp();

A. Object b can t access disp() function
B. Object b can access disp() function inside its body
C. Object b can t access members of class A
D. Program runs fine
Answer» B. Object b can access disp() function inside its body
913.

Protected members differ from default members as_______ class A { protected : int marks; public : A() { marks=100; } disp() { cout<< marks= <<marks; } }; class B: protected A { }; B b; b.disp();

A. Protected members can be accessed outside package using inheritance, but default can t
B. Default members can be accessed outside package using inheritance, but protected can t
C. Protected members are allowed for inheritance but Default members are not allowed
D. Both are same
Answer» B. Default members can be accessed outside package using inheritance, but protected can t
914.

Which among the following is correct for the code given. class A { private: int marks; A() { } Public : disp() { cout<< marks; } }; class B: public A { } B b;

A. Instance of B will not be created
B. Instance of B will be created
C. Program gives compile time error
D. Program gives runtime error
Answer» B. Instance of B will be created
915.

PHP has long supported two regular expression implementations known as _______ and _______i) Perlii) PEARiii) Pearliv) POSIX

A. I) and ii)
B. Ii) and iv)
C. I) and iv)
D. Ii) and iii)
Answer» D. Ii) and iii)
916.

Which of the following would be a potential match for the Perl-based regular expression /fo{2,4}/ ?i) folii) fooliii) fooooliv) fooooool

A. Only i)
B. Ii) and iii)
C. I), iii) and iv)
D. I) and iv)
Answer» C. I), iii) and iv)
917.

Which among the following is/are not a metacharacter?i) aii) Aiii) iv) B

A. Only i)
B. I) and iii)
C. Ii), iii) and iv)
D. Ii) and iv)
Answer» B. I) and iii)
918.

Say we have two compare two strings which of the following function/functions can you use?i) strcmp()ii) strcasecmp()iii) strspn()iv) strcspn()

A. I) and ii)
B. Iii) and iv)
C. None of the mentioned
D. All of the mentioned
Answer» E.
919.

Which among the following is true for the code given below:a) Only object of class A can access disp() function class A { int marks; public : disp() { cout<<marks; } } class B: protected A { char name[20]; } A a; a.disp(); B b; b.disp();

A. Only object of class A can access disp() function
B. Only object of class B can access disp() function
C. Both instances can access disp() function
D. Accessing disp() outside class is not possible
Answer» B. Only object of class B can access disp() function
920.

What will be the output of the program given below: class A { Public : A(int a=0) { cout<< new A ; } }; A a; A b; A c;

A. New A new A new A
B. NewAnewAnewA
C. New Anew Anew A
D. New A new Anew A
Answer» D. New A new Anew A
921.

What will be the output of the following PHP code? Say your previous session username was nachi. <?php unset($_SESSION['username']); printf("Username now set to: %s", $_SESSION['username']); ?>

A. Username now set to: nachi
B. Username now set to: System
C. Username now set to:
D. Error
Answer» D. Error
922.

What will be the output of the following PHP code if date is 24/02/2008? <?php $date = new DateTime(); echo $date->format('l,F,js,Y') ?>

A. Sunday, February 24th 2008
B. Sunday, 02 24 2008
C. Sunday, 24 02 2008
D. Sunday, 24th February 2008
Answer» B. Sunday, 02 24 2008
923.

Among the four PHP DateTimeZone classes given below how many are static? i) _construct() ii) getName() iii) getOffset() iv) getTransitions()

A. 1
B. 2
C. 3
D. 4
Answer» C. 3
924.

Among the four PHP DateTimeZone classes given below how many are non static?i) _construct()ii) getName()iii) getOffset()iv) getTransitions()

A. 1
B. 2
C. 3
D. 4
Answer» E.
925.

What will be the output of the following PHP code ? <?php if (print "hi" - 1) print "hello" ?>

A. Hi
B. Hihello
C. Error
D. No output
Answer» D. No output
926.

What will be the output of the following PHP code ? <?php $x = 1; if ($x--) print "hi" $x--; else print "hello" ?> a) hi

A. Hi
B. Hello
C. Error
D. No output
Answer» D. No output
927.

What will be the output of the following PHP code ? <?php $a = 10; $b = 11; if ($a < ++$a || $b < ++$b) print "hello"; else print "hi"; ?>

A. Hi
B. Hello
C. Error
D. No output
Answer» B. Hello
928.

What will be the output of the following PHP code ? <?php $a = 2; if ($a-- - --$a - $a) print "hello"; else print "hi"; ?>

A. Hi
B. Hello
C. Error
D. No output
Answer» C. Error
929.

What will be the output of the following PHP code ? <?php $a = 2; if ($a-- - --$a - $a) print "hello"; else print "hi"; $a = "hello"; if ($a.length) print $a.length; else print "hi"; ?>

A. Hellolength
B. 5
C. Hi
D. Error
Answer» B. 5
930.

What will be the output of the following PHP code ? <?php $a = "hello"; if (strlen($a)) print strlen($a); else print "hi"; ?>

A. Hellolength
B. 5
C. Hi
D. Error
Answer» C. Hi
931.

What will be the output of the following PHP code ? <?php for ($count = 0; $count < 3;$count++); { print "hi";continue;print "hello"; } ?>

A. Hihihi
B. Hihellohihellohihello
C. Hellohellohello
D. Hi
Answer» B. Hihellohihellohihello
932.

What will be the output of the following PHP code ? <?php $a = "1"; switch ($a) { case 1: print "hi"; case 2: print "hello"; default: print "hi1"; } ?>

A. Hihellohi1
B. Hi
C. Hihi1
D. Hi1
Answer» B. Hi
933.

What will be the output of the following PHP code ? <?php $a = "1"; $b = "0"; if ((int)$a && $b) print"hi"; else print "hello"; ?>

A. Hello
B. No output
C. Hi
D. Error
Answer» B. No output
934.

What will be the output of the following PHP code ? <?php for ($count = 0; $count<3;$count++); { print "hi";break;print "hello"; } ?>

A. Hihihi
B. Hihellohihellohihello
C. Hellohellohello
D. Hi
Answer» E.
935.

What will be the output of the following PHP code ? <?php for(++$i; ++$i; ++$i) { print $i; if ($i == 4) break; } ?>

A. 24
B. 134
C. 1234
D. 1
Answer» B. 134
936.

What will be the output of the following PHP code ? <?php for ($i = 0;$i = -1;$i = 1) { print $i; if ($i != 1) break; } ?>

A. 0
B. Infinite loop
C. -1
D. 1
Answer» D. 1
937.

What will be the output of the following PHP code ? <?php for(;;) { print "10"; } ?>

A. 10
B. Infinite loop
C. No output
D. Error
Answer» C. No output
938.

What will be the output of the following PHP code ? <?php for ($i = 0; -5 ; $i++) { print"i"; if ($i == 3) break; } ?>

A. 0 1 2 3 4
B. 0 1 2 3
C. 0 1 2 3 4 5
D. Error
Answer» C. 0 1 2 3 4 5
939.

What will be the output of the following PHP code ? <?php for ($i = 0; 0; $i++) { print"i"; } ?>

A. Infinite loop
B. 0
C. No output
D. Error
Answer» D. Error
940.

What will be the output of the following PHP code ? <?php for ($i = 0; $i < 5; $i++) { for ($j = $i; $j > 0; $i--) print $i; } ?>

A. Infinite loop
B. 0 1 2 3 4 5
C. 0 1 0 1 2 0 1 2 3 0 1 2 3 4 0 1 2 3 4 5 0 1 2 3 4 5
D. No output
Answer» B. 0 1 2 3 4 5
941.

What will be the output of the following PHP code ? <?php for ($i = 0; $i < 5; $i++) { for ($j = $i;$j > $i; $i--) print $i; } ?>

A. Infinite loop
B. 0 1 2 3 4 5
C. 0 1 0 1 2 0 1 2 3 0 1 2 3 4 0 1 2 3 4 5 0 1 2 3 4 5
D. No output
Answer» E.
942.

What will be the output of the following PHP code ? <?php $user = array("Ashley", "Bale", "Shrek", "Blank"); for ($x = 0; $x < count($user); $x++) { if ($user[$x] == "Shrek") continue; printf ($user[$x]); } ?>

A. AshleyBaleBlank
B. AshleyBale
C. AshleyBaleShrek
D. No output
Answer» B. AshleyBale
943.

What will be the output of the following PHP code ? <?php $user = array("Ashley", "Bale", "Shrek", "Blank"); for ($x=0; $x < count($user) - 1; $x++) { if ($user[$x++] == "Shrek") continue; printf ($user[$x]); } ?>

A. AshleyBaleBlank
B. Bale
C. AshleyShrek
D. BaleBlank
Answer» B. Bale
944.

What will be the output of the following PHP code ? <?php $user = array("Ashley", "Bale", "Shrek", "Blank"); for ($x = 0; $x < count($user); $x) { if ($user[$x++] == "Shrek") continue; printf ($user[$x]); } ?>

A. AshleyBaleBlank
B. BaleShrek
C. AshleyBlank
D. Bale
Answer» C. AshleyBlank
945.

What will be the output of the following PHP code ? <?php for ($i = 0; $i % ++$i; $i++) { print"i"; } ?>

A. Error
B. Infinite loop
C. No output
D. 0
Answer» C. No output
946.

What will be the output of the following PHP code ? <?php $i = 0; while(++$i || --$i) { print $i; } ?>

A. 1234567891011121314 .infinitely
B. 01234567891011121314 infinitely
C. No output
D. Error
Answer» D. Error
947.

What will be the output of the following PHP code ? <?php $i = 0; while ((--$i > ++$i) - 1) { print $i; } ?>

A. 210
B. 10
C. No output
D. Infinite loop
Answer» B. 10
948.

What will be the output of the following PHP code ? <?php $i = 2; while (++$i) { while (--$i > 0) print $i; } ?>

A. 0
B. Infinite loop
C. No output
D. Error
Answer» E.
949.

What will be the output of the following PHP code ? <?php for ($x = 0; $x <= 10; print ++$x) { print ++$x; } ?>

A. 123456789101112
B. 12345678910
C. 1234567891011
D. Infinite loop
Answer» B. 12345678910
950.

What will be the output of the following PHP code ? <?php for ($x = 1; $x < 10;++$x) { print "* t"; } ?>

A. **********
B. *********
C. ***********
D. Infinite loop
Answer» C. ***********