Basic Programming MCQ

What is the size of the int data type (in bytes) in C?
4
8
2
1
Which of the following is an exit controlled loop?
While Loop
For Loop
Do-While Loop
None of the Above
Which of the following are not standard header files in C?
Stdio.h
Conio.h
Stdlib.h
None Of the Above
In which of the following languages is function overloading not possible?
C
C++
Java
Python
Which function is used to serialize an object into a JSON string in Javascript?
Stringify()
Parse()
Convert()
None of the above
What keyword is used to declare an asynchronous function in Javascript?
Async
Await
SetTimeout
None of the above
How to stop an interval timer in Javascript?
ClearInterval
ClearTimer
IntervalOver
None of the above
How are objects compared when they are checked with the strict equality operator?
The contents of the objects are compared
Their references are compared
Both A and B
None of the above
Which object in Javascript doesn’t have a prototype?
Base Object
All objects have a prototype
None of the objects have a prototype
None of the above
What is the implicit return type of constructor?
No return type
A class object in which it is defined.
Void
None
When is the object created with a new keyword?
At run time
At compile time
Depends on the code
None
Identify the incorrect constructor type.
Friend constructor
Default constructor
Parameterized constructor
Copy constructor
Identify the scope resolution operator.
:
::
?:
None
Choose the option below which is not a member of the class.
Friend function
Static function
Virtual function
Const function
What is the number of parameters that a default constructor requires?
0
1
2
3
Data members and member functions of a class are private. default. True or False?
True
False
Depends on code
None
Under which pillar of OOPS do base class and derived class relationships come?
Polymorphism
Inheritance
Encapsulation
Abstraction
Which of the following functions can be inherited from the base class?
Constructor
Destructor
Static
None
Why is reusability a desirable feature?
Reduces compilation time
Decreases testing time
Lowers maintenance cost
None
Another name of overloading is?
Pseudo polymorphism
Transient polymorphism
Virtual polymorphism
Ad-hoc polymorphism
By default, fields in a structure of a C program is?
Public
Private
Protected
None
Total access specifiers in OOPS for C++ are?
1
2
3
4
To access data members of a class, which of the following is used?
Dot operator
Arrow operator
Dot or arrow operator, as required
Dot, arrow, or direct call
Identify the feature, which is used to reduce the use of nested classes.
Binding
Inheritance
Encapsulation
Abstraction
In which of the following is memory allocated for the objects?
RAM
ROM
Cache
HDD
Choose the option below which is shown by function overriding
Abstraction
Encapsulation
Polymorphism
Inheritance
Dynamic memory allocation can be done using?
Calloc()
Malloc()
Both (a) and (b)
Create()
Total types of polymorphism in C++ are?
1
2
3
4
Choose the option below which is used to implement late binding.
Friend function
Static function
Virtual function
Const function
What will be the output of the following code snippet?
(function(){
 setTimeout(()=> console.log(1),2000);
 console.log(2);
 setTimeout(()=> console.log(3),0);
 console.log(4);
})();
1 2 3 4
2 3 4 1
2 4 3 1
4 3 2 1
What will be the output of the following code snippet?
(function(a){
 return (function(){
   console.log(a);
   a = 6;
 })()
})(21);
6
NaN
21
None of the above
What will be the output of the following code snippet?
function solve(arr, rotations){
 if(rotations == 0) return arr;
 for(let I = 0; I < rotations; i++){
   let element = arr.pop();
   arr.unshift(element);
 }
 return arr;
}
// solve([44, 1, 22, 111], 5);
[111, 44, 1, 22]
[44, 1, 22, 111]
[111, 44, 1, 22]
[1, 22, 111, 44]
What will be the output of the following code snippet?
var a = 1;
var b = 0;
while (a <= 3)
{
a++;
b += a * 2;
print(b);
}
4 10 18 c
1 2 3
1 4 7
None of the above
What is the output of the following code snippet?
print(NaN === NaN);
True
False
Undefined
Error
What will be the output of the following code snippet?
var a = true + true + true * 3;
print(a)
3
0
Error
5
What will be the output of the following code snippet?
let sum = 0; 
const a = [1, 2, 3];
a.forEach(getSum);
print(sum);
function getSum(ele) {
   sum += ele;
}
6
1
2
None of the above
What will be the output of the following code snippet?
a = [1, 2, 3, 4, 5];
print(a.slice(2, 4));
3, 4
2, 3
3, 4, 5
2, 3, 4
What will be the output of the following code snippet?
const obj1 = {Name: "Hello", Age: 16};
const obj2 = {Name: "Hello", Age: 16};
print(obj1 === obj2);
True
False
Undefined
None of the above
What will be the output of the following code snippet?
print(parseInt("123Hello"));
print(parseInt("Hello123"));
123 NaN
123Hello Hello123
NaN NaN
123 123
What will be the output of the following code snippet?
#include 
void solve() {
    int first = 10, second = 20;
    int third = first + second;
    {
        int third = second - first;
        printf("%d ", third);
    }
    printf("%d", third);
}
int main() {
	solve();
	return 0;
}
10 30
30 10
10 20
20 10
What will be the output of the following code snippet?
#include 
void solve() {
    int a = 3;
    int res = a++ + ++a + a++ + ++a;
    printf("%d", res);
}
int main() {
	solve();
	return 0;
}
12
24
20
18
What will be the output of the following code snippet?
#include 
#define VAL 3 * (2 + 6)
void solve() {
    int a = 10 + VAL;
    printf("%d", a);
}
int main() {
	solve();
	return 0;
}
104
24
34
12
What will be the output of the following code snippet?
#include 
struct School {
    int age, rollNo;
};
void solve() {
    struct School sc;
    sc.age = 19;
    sc.rollNo = 82;
    printf("%d %d", sc.age, sc.rollNo);
}
int main() {
    solve();
	return 0;
}
19 82
Compilation Error
82 19
None of the Above
Which data structure is used to handle recursion in C?
Stack
Queue
Tree
Root
Which of the following is not true about structs in C?
No Data Hiding.
Functions are allowed inside structs.
Constructors are not allowed inside structs.
Cannot have static members in the struct body.
What does the abbreviation HTML stand for?
HyperText Markup Language.
HighText Markup Language.
HyperText Markdown Language.
None of the above.
How many sizes of headers are available in HTML by default?
5
1
3
6
What are the types of lists available in HTML?
Ordered, Unordered Lists.
Bulleted, Numbered Lists.
Named, Unnamed Lists.
None of the above.
Which of the following tags doesn’t require a closing tag?
<br>
<hr>
Both A and B
None of the above
Which of the following properties is used to change the font of text?
Font-family
Font-size
Text-align
None of the above
Which of the following tags is used to add a row to a table in HTML?
<tr>
<td>
<th>
None of the above
How many characters can be written in 1KB?
1048
1024
1000
None of the above
What are the main components of the front end of any working website?
HTML, CSS, Javascript.
HTML only.
Javascript only.
Node.js.
What is used for storing data on the client side provided by the HTML locally?
Windows.localStorage
Window.sessionStorage
Both A and B
None of the above
Which of the following is true about HTML tags?
Are case sensitive
Are not case sensitive
Are in uppercase
Are in lowercase
Javascript is an _______ language?
Object-Oriented
Object-Based
Procedural
None of the above
Which of the following keywords is used to define a variable in Javascript?
Var
Let
Both A and B
None of the above
Which of the following methods is used to access HTML elements using Javascript?
GetElementbyId()
GetElementsByClassName()
Both A and B
None of the above
Which of the following methods can be used to display data in some form using Javascript?
Document.write()
Console.log()
Window.alert()
All of the above
What keyword is used to check whether a given property is valid or not?
In
Is in
Exists
Lies
{"name":"Basic Programming MCQ", "url":"https://www.quiz-maker.com/QPREVIEW","txt":"What is the size of the int data type (in bytes) in C?, Which of the following is an exit controlled loop?, Which of the following are not standard header files in C?","img":"https://www.quiz-maker.com/3012/images/ogquiz.png"}
Make your own Survey
- it's free to start.