Articles by "Computer Science MCQ"
Showing posts with label Computer Science MCQ. Show all posts
no image
This Blog is particularly related to different programming subjects. It helps students of MCA, BCA, B.Tech, M.Tech, M.Sc(IT), PGDCA.
Predict the output of the following coding question on C language:

1. Find the output of the following code?
int main()
{
char *str = "hello, world";
char *str1 = "hello, world";
if (strcmp(str, str1))
printf("equal");
else
printf("unequal");
}


2. Find the output of the following code?
void main()
{
char *str = "hello";
char str1[5];
strcpy(str1, str);
printf("%s", str1);
}

3. Find the output of the following code?
void main()
{
char *str = "hello, world";
char str1[9];
strncpy(str1, str, 9);
printf("%s %d", str1, strlen(str1));
}

4. Find the output of the following code?
int xstrlen(char *s)
{
int length=0;
while(*s!='\0')
{
length++;
s++;
}
return (length);
}

5. Find the output of the following code?
int main()
{
char str1[20] = "C ", str2[20] = "Programming";
printf("%s\n", strcpy(str2, strcat(str1, str2)));
return 0;
}

6. Find the output of the following code?
int main()
{
char *names[] = { "A", "B", "C", "D", "E"};
int i;
char *t;
t = names[3];
names[3] = names[4];
names[4] = t;
for(i=0; i<=4; i++)
printf("%s\t", names[i]);
return 0;
}

7. Find the output of the following code?
int main()
{
static char str1[] = "C";
static char str2[20];
static char str3[] = "Programming";
int i;
i = strcmp(strcat(str3, strcpy(str2, str1)), "Computers");
printf("%d\n", i);
return 0;
}


8. Find the output of the following code?
int main()
{
static char s[] = "Hello!";
printf("%d\n", *(s+strlen(s)));
return 0;
}


no image
This Blog is particularly related to different programming subjects. It helps students of MCA, BCA, B.Tech, M.Tech, M.Sc(IT), PGDCA.
Predict the output of the following coding questions of C Language:

1. What is the output of the following code?
#include <stdio.h>
int main()
{
unsigned int a = 10;
a = ~a;
printf("%d\n", a);
}


2. What is the output of the following code?
int i=40;
extern int i;
int main()
{
do
{
printf("%d",i++);
}while (5, 4, 3, 2, 1, 0);
return 0;
}

3. What is the output of the following code?
int main()
{
int i;
for(i=10;i<=15;i++)
{
while(i)
{
do
{
printf("%d ",1);
if(i>>1)
continue;
}while(0);
break;
}
}
return 0;
}


4. What is the output of the following code?
void main()
{
double k = 0;
for (k = 0.0; k < 3.0; k++)
printf("Hello");
}

5. What is the output of the following code?
void main()
{
int i = 0;
for (i++; i == 1; i = 2)
printf("In for loop ");
printf("After loop\n");
}

6. What is the output of the following code?
void main()
{
int i = 0;
while (i < 10)
{
i++;
printf("hi\n");
while (i < 8)
{
i++;
printf("hello\n");
}
}
}


7. What is the output of the following code?
void main()
{
int i = 0, j = 0;
while (i < 5, j < 10)
{
i++;
j++;
}
printf("%d, %d\n", i, j);
}

8. What is the output of the following code?
void main()
{
int i, j;
for (i = 0;i < 5; i++)
{
for (j = 0;j < 4; j++)
{
if (i > 1)
break;
}
printf("Hi \n");
}
}


9. What is the output of the following code?
void main()
{
int i, j;
for (i = 0;i < 5; i++)
{
for (j = 0;j < 4; j++)
{
if (i > 1)
continue;
printf("Hi \n");
}
}
}

10. What is the output of the following code?
void main()
{
int i;

for(i = 2;i += 2; i <= 9; i +=2)
printf(“%d\n”, i);
}




no image
This Blog is particularly related to different programming subjects. It helps students of MCA, BCA, B.Tech, M.Tech, M.Sc(IT), PGDCA.
Predict the output of the following coding questions of C language:

1. Find the output of the following code?
void main()
{
int a[2][3] = {1, 2, 3, 4, 5};
int i = 0, j = 0;

for (i = 0; i < 2; i++)
for (j = 0; j < 3; j++)
printf("%d\t", a[i][j]);
}

2. Find the output of the following code?
void main()
{
int a[2][2] = {{2,3},{1,6}};
printf("%d", &a[0][1] - &a[0][0]);
}

3. What is the size of the array arr if it is declared as, float arr[3][2][2]?


4. Find the output of the following code?
void main()
{
char data[2][3][2]={0,1,2,3,4,5,6,7,8,9,10,11};
printf("%o",data[0][2][1]);
}

5. Find the output of the following code?
void main()
{
short num[3][2]={3,6,9,12,15,18};
printf("%d %d",*(num+1)[1],**(num+2));
}

6. Find the output of the following code?
void main()
{
char *ptr="c programming";
printf("%c",3[ptr]);
}


7. Find the output of the following code?
void main()
{
int array[2][3]={5,10,15,20,25,30};
int (*ptr)[2][3]=&array;
printf("%d\t",***ptr);
printf("%d\t",***(ptr+1));
printf("%d\t",**(*ptr+1));
printf("%d\t",*(*(*ptr+1)+2));
}

8. Find the output of the following code?
void main()
{
int arr[][3]={{1,2},{3,4,5},{5}};
printf("%d %d %d",sizeof(arr),arr[0][2],arr[1][2]);
}

9. Find the output of the following code?
void main()
{
char arr[20]="Mahendra Singh Dhoni";
printf("%d",sizeof(arr));
}


10. Find the output of the following code?
void main()
{
int a[5] = {5, 1, 15, 20, 25};
int i, j, m; i = ++a[1]; j = a[1]++;
m = a[i++]; printf("%d, %d, %d", i, j, m);
}

11. What is the output of the following program?
int a[6] = {2, 7, 3, 1, 5, 9};
printf(“%d”,a[5] + 6);

12. What will be the output of the following code ?
void main()
{
int a[5]={3,5,6,2,7};
int i=3;
if(a[i]==a[i+3])
printf("true");
else
printf("false");
}

13. What will be the output of the following code ?
void main()
{
int a[5] = {5,7,3,1,2};
a[2]=a[1];
a[1]=a[3];
a[2]=a[2]+a[3];
printf("%d\t%d", a[1],a[2]);
}


14. Write the output of the following code?
void main()
{
int a[3][2] = {10. 20, 30, 40, 50, 60};
printf(“%d”, a[0][4]);
}

15. Write the output of the following code?
void main()
{
int x[10] = {5};
printf(“%3d%3d”, x[1], x[9]);
}
no image
This Blog is particularly related to different programming subjects. It helps students of MCA, BCA, B.Tech, M.Tech, M.Sc(IT), PGDCA.
Predict the output type Questions of C Language:

1. Find the output of the following code?
void main()
{
int i=10;
i = !i > 14;
printf(“i=%d”,i);
}


2. Find the output of the following code?
void main()
{
int i=0, j=1, k=2,m;
m = i++ || j++ || k++;
printf(%3d%3d%3d%3d”, m, i, j, k);
}

3. Find the output of the following code?
void main()
{
int main=3;
printf(“%d”, main);
}

4. Find the output of the following code?
void main()
{
int k;
k = ‘a’ > 60;
printf(“%d”, k);
}

5. Find the output of the following code?
void main()
{
printf(“iare\rcollege\n”);
}

6. Find the output of the following code?
void main()
{
int const k = 5;
k++;
printf(“k is %d”, k);
}

7. Find the output of the following code?
int x;
void main()
{
if (x)
printf("hi");
else
printf("how are u");
}

8. Find the output of the following code?
void main()
{
int x = 0;
if (x == 0)
printf("hi");
else
printf("how are u");
printf("hello");
}

9. Find the output of the following code?
void main()
{
int x = 5;
if (x < 1);
printf("Hello");
}

10. Find the output of the following code?
void main()
{
int ch;
printf("enter a value btw 1 to 2:");
scanf("%d", &ch);
switch (ch)
{
case 1: printf("1\n");
default:printf("2\n");
}
}

11. Find the output of the following code?
void main()
{
char ch;
int i;
ch = 'G';
i = ch-'A';
printf("%d", i);
}

12. Find the output of the following code?
void main()
{
int i=065, j=65;
printf(%4d%4d”,i, j);
}

13. Find the output of the following code?
void main()
{
unsigned int a = 10;
a = ~a;
printf(“%d\n”, a);
}

14. Find the output of the following code?
void main()
{
int x = 97;
int y = sizeof(x++);
printf(“x is %d”,x);
}

15. Find the output of the following code?
void main()
{
int x = 4, y, z;
y = --x;
z = x--;
printf(“%3d%3d%3d”, x, y, z);
}
no image
This Blog is particularly related to different programming subjects. It helps students of MCA, BCA, B.Tech, M.Tech, M.Sc(IT), PGDCA.
MCQ of JAVA Programming

1. What is an array?
An array is a collection of elements of same data type referred by a common name.The elements are of the array are stored in consecutive memory locations.

2. What are the types of arrays?
One dimensional array, the two-dimensional array, and multidimensional arrays.


3. How to declare a two-dimensional array?
Datatype arrayname[][]=new datatype[ row size][column size]

4. How the individual elements of an array can be accessed?
The individual elements can be accessed using the index. The index of the first element starts with 0.

5. What is Vector?
Vector is just like an array that can store elements of different data types. The elements of the vector can only be objects. So the primitive data type must be converted into object data type before adding to the vector.

6. What is the difference between capacity and size of the Vector?
Capacity specifies the maximum number of objects that can be stored in the vector. Size specifies the number of objects that are present in the Vector.

7. What is the difference between an array and Vector?
The elements of the array are of the same data type. The elements of the Vector can be a different data type. The elements of the array can be of the primary data type. The elements of the Vector can only be objects. The capacity of the array is fixed. The size of Vector can be changed during Runtime.

8. What is a class?
A class is a collection of data and methods that define an object. The variables and methods (functions) of a class are called members of the class.

9. What is an object?
The variable of type class is called object.
Syntax for defining a class
class className
{
//Declaration of instance variables
//Constructors
//Instance Methods
}

10. How can we create objects?
The objects can be created using the new operator. className objectNname=new className();

11. How the members of a class can be accessed?
The members of the class can be accessed using the dot operator
Objectname .variable
Or
Objectname.methodName(Arguments)

12. What is a constructor?
Constructors are special methods whose name is same as the class name. The constructors do not return any value. The constructors are automatically called when an object is created. They are usually used to initialize the member variables.


13. What is a default constructor?
Constructor that does not take any argument is called the default constructor.

14. What is meant by constructor overloading?
Defining more than one constructor for a class which differs in the number of arguments/type of arguments or both is called constructor overloading.

15. What is inheritance?
Inheritance is the process of deriving a new class from an existing class. The newly created class is called subclass and the already existing class is called superclass.

16. What are the types of inheritance?
Single inheritance: One superclass and single subclass.
Multiple inheritances: More than one superclass and single subclass.
Hierarchical inheritance: one superclass and more than one subclass.

Multilevel inheritance: Deriving a subclass from another subclass
Syntax for deriving a subclass
class subclassName extends superclass-name
{
//define the members
}
This Blog is particularly related to different programming subjects. It helps students of MCA, BCA, B.Tech, M.Tech, M.Sc(IT), PGDCA.
Java Short Answer type Questions



1.What are command line arguments?
The values that are passed to the main method from the command line while executing the program are called as command line arguments.

2. What are the various types of operators available in java?


Arithmetic operator, Relational operator, Logical operator, Bitwise operator, Increment and decrement operator, Assignment operator, Conditional operator and Special Operator.

3. What is a ternary operator?
The operator that takes three arguments is called as the ternary operator. The conditional operator is the only ternary operator available in java.

4. What is the use of Integer.parseInt() method?
This method is used to convert the String object into an integer value.

5. What is called as a Boolean expression?
An expression that returns either true or false value is called a Boolean expression.

6. What is a control structure?
Control structures are statements that are used to change the flow of the program based on some condition.

7. What are the two types of control structures?
Decision-making statements and Looping statements

8. What is decision making statements?
The statements that are used to execute only a block of code and leaving others based on the condition.

9. What is the use looping statement?
The looping statement is used to execute a block of repeatedly until the condition is true.

10. What is the difference between while and do..while?


In case of while statement the block of code will not be executed at least once if the condition is false at the first run.
In case of do..while statement the block of code will be executed at least once if the condition is false at the first run.