1) Which of the following is not true about C Programming?
C provides function oriented programming
C program can be compiled on a C++ compiler

Solution

C supports encapsulation is false. Only C++ supports encapsulation

2) What will be effect of sizeof operator on Unions?

gives the size of the biggest member

gives the size of sum of all members

gives the size of the smallest of the members

Correct Answer: gives the size of the biggest member

3) Divide by Zero is a common exception of type

Run Time
Compile Time
can be either Run time or Compile time

Answer: Run Time


4) Find the output of the code snippet

char *S1 = "ABCD";
char S2[ ] = "ABC";
printf("%d,%d",sizeof(S1), sizeof(S2));

a) 3,4
b) 4,4
c) 3,3

Output: 4,4. S1 is a character pointer giving the size of the pointer variable. Second one is a character array

with size 4. (Including the terminating character '\0').

5) Find the output of the code snippet

int i ;
int v = scanf("%d",&i); // Lets say the input is 23
printf("%d",v);

a)23
b)1
c)Junk

Anwer:

Output = 1;
This is because, scanf reads and input and returns the number of items read. Hence 23 would be stored in i and 1

would be stored in v

6) What is the default size of a integer variable ?

a) 2 bytes
b) 4 bytes
c) can be 2 or 4 depending on the operating system

Answer:
can be 2 or 4 depending on the operating system

7) Which of the following statements is false?

a)Pointers are designed for storing memory addresses
b)Arrays are passed by value to functions
c)Both of the above are false

Answer: Both of the above are false

8) Which of the following statements is true regarding static variables?

a) Which of the following statements is true regarding static variables?
b) Only local variables can be defined as static variables
c) Scope and life of global variables is limited to the function to which they are declared

Answer: Both local and global variables can be defined as static variables

9) An ampersand in front of a pointer variable gives

a) address of the value
b) value present at the address
c) depends on the actual scenario

Answer: a) Address of the value

10) Which of the following is not true about C Programming?

a)C provides function oriented programming
b)C program can be compiled on a C++ compiler
c)C supports encapsulation

Answer is C supports encapsulation

11) What will be effect of sizeof operator on Unions?

a) gives the size of the biggest member
b)gives the size of sum of all members
c)gives the size of the smallest of the members

Answer is gives the size of sum of all members

12) Divide by Zero is a common exception of type

a)Runtime
b)Compile Time
c)can be either Run time or Compile time

Answer is Runtime

13)Find the output of the code snippet
char *S1 = "ABCD";
char S2[ ] = "ABC";
printf("%d,%d",sizeof(S1), sizeof(S2));

a)3,4
b)4,4
c)3,3

Answer is 4,4


14) What are identifiers and what is naming convention?

Ans : Identifiers are used for class names, method names and variable names. An identifier may be any descriptive sequence of upper case & lower case letters,numbers or underscore or dollar sign and must not begin with numbers.

15) What is the return type of program’s main( ) method?

Ans : void

16) What is the use of bin and lib in JDK?

Ans : Bin contains all tools such as javac, applet viewer, awt tool etc., whereas Lib contains all packages and variables.

17) The Java source code can be created in a Notepad editor.

a) True
b) False

Ans: True


18) The Java interpreter is used for the execution of the source code.

True
False

Ans: True

19) What declarations are required for every Java application?

Ans: A class and the main( ) method declarations.

20) What are the two parts in executing a Java program and their purposes?

Ans: Two parts in executing a Java program are:
Java Compiler and Java Interpreter.
The Java Compiler is used for compilation and the Java Interpreter is used for execution of the application.

21) What are the three OOPs principles and define them?

Ans : Encapsulation, Inheritance and Polymorphism are the three OOPs Principles.
Encapsulation:
Is the Mechanism that binds together code and the data it manipulates, and keeps both safe from outside interference and misuse.
Inheritance:
Is the process by which one object acquires the properties of another object.
Polymorphism:
Is a feature that allows one interface to be used for a general class of actions.