404

الصفحه التي تبحث عنها غير موجوده

MCQ of C# with Answer set-3

0

MCQs in C#
MCQs in C#
1. The general syntax for declaring an enumeration in C# is .

A) <enum_name> enum {enum list};

B) enum <enum_name> {enum list};

C) <enum_type> enum <enum_name> {enum list};

D) None of the above


2. State True or False for the difference between classes and structures.

i) Structures do not support inheritance

ii) Structure can have default constructor

iii) Classes are reference types and structures are value types.

A) i- True, ii- False, iii-True

B) i- False, ii- True, iii-True

C) i-True, ii-True, iii-False

D) i- False, ii- False, iii-True


3. The various techniques provided by C# to implement static polymorphism is/are

i) Function overloading

ii) Static overloading

iii) Operator overloading

A) i and ii only

B) i and iii only

C)  ii and iii only

D) All i, ii, iii


4. Operator overloading is creating functions with special names, the keyword ........................ operator followed by the symbol for the operator being defined.

A) Overload

B) Update

C) Operator

D) Implement


5. Match the following operators in C# with their description for the operator overload property.

i) +, -, !, ~, ++, --            a) cannot be overloaded

ii) ==, !=, <, >, <=, >=    b) cannot be overloaded directly

iii) &&, ||                         c) take one operand and can be overloaded

iv) =, ., ? :, ->                  d) can be overload

A) i-d, ii-c, iii-a, iv-b

B) i-b, ii-c, iii-a, iv-d

C) i-c, ii-d, iii-b, iv-a

D) i-a, ii-c, iii-d, iv-b


6. Match the following preprocessor directives in C# with their description?

i) #elif                      a) specifies the end of conditional directive

ii) #endif                   b) allows to undefine a symbol.

iii) #undef                  c) allows creating compound conditional directive

A) i-b, ii-c, iii-a

B) i-b, ii-c, iii-a

C) i-c, ii-a, iii-b

D) i-a, ii-c, iii-b


7. The operator symbols can be used for the conditional directives in C# is/are.

i) = = (equality)         ii) ! = (inequality)            iii) && (and)

iv) || (or)                   v) >= (grater than or equal to)

A) i, ii  iii and iv only

B) i, iii and iv only

C) i, ii, iii and v only

D) All i, ii, iii, iv and v


8. Conditional directives are beginning with a ...................... directive and must be terminated with ....................... directive and must be terminated with .............. directive.

A) #if, #endif

B) #start, #end

C) #elif, #endelif

D) Both A and B


9. The keywords provided by C# for exception handling are.

i) try             ii) catch             iii) finally             iv) tryif             v) throw

A) i, ii and iii and iv only

B) ii, iii and iv and v only

C) i, ii and iii and v only

D) All i, ii, iii and iv


10. The ................... block is used to execute a given set of statement, whether the exception is thrown or not.

A) try

B) tryif

C) finally

D) throw


Answers:

1.   B) enum <enum_name> {enum list};
2.   A) i- True, ii- False, iii-True
3.   B) i and iii only
4.   C) Operator
5.   C) i-c, ii-d, iii-b, iv-a
6.   C) i-c, ii-a, iii-b
7.   A) i, ii and iii and iv only
8.   A) #if, #endif
9.   C) i, ii and iii and v only
10. C) finally


You Might also view the following Related Posts

Objective Questions of C# with Answer set-2

0
C# MCQs
Objective Questions in C#

1. In C# variables are categorized into ..........

i) Value types          ii) Reference types              iii) initial types             iv) pointer types

A) i, ii and iii only

B) ii, iii and iv only

C) i, ii and iv only

D) All i, ii, iii and iv


2. Value type variables can be assigned a value directly which are derived from the class

A) System.value

B) System.ValueType

C) General.ValueType

D) Variable.ValueType


3. The various data types used in C# are

i) Integral Type           ii) Floating point types

iii) Boolean types       iv) Nullable types

A) i, ii and iii only

B) ii, iii and iv only

C) i, iii and iv only

D) All i, ii, iii and iv


4. The built-in operators that are provided by C# programming language are...

i) Arithmetic operators          ii) Logical operators

iii) Bitwise operators             iv) Assignment operators

A) i, ii and iii only

B) ii, iii and iv only

C) i, iii and iv only

D) All i, ii, iii and iv


5. Match the different Bitwise operators supported by C# with their descriptions.

i) &                   a) Binary Left Shift Operator

ii) ^                   b) Binary Right Shift Operator

iii) <<               c) Binary XOR operator

iv) >>               d) Binary AND operator

A) i-d, ii-c, iii-a, iv-b

B) i-b, ii-c, iii-a, iv-d

C) i-c, ii-a, iii-b, iv-d

D) i-a, ii-c, iii-d, iv-b



6. What will be the value of the following expression if x=10?

A) 25

B) -5

C) 10

D) 15


7. While passing parameter to a method ................ copies the actual value of an argument into the formal parameter of the function.

A) Output Parameter

B) Value Parameter

C) Reference Parameter

D) Initial Parameter


8. In C# methods can be defined by using which of the following syntex?

A) <Method Name> (parameter list) { Method body }

B) <Method Name> <Return Type> <Access Specifier> (parameter list) { Method body }

C) <Return Type> <Method Name> <Access Specifier> (parameter list) { Method body }

D) None of the above


9. Which of the following are the methods to assign values to an array?

i) double [ ] score = {234.0, 214.5, 572.0};

ii) int [ ] marks = new int [3] {33, 45, 67};

iii) int [ ] marks = new int [ ] {33, 45, 67};

A) i and ii only

B) ii and iii only

C) i and iii only

D) All i, ii, iii


10. State whether the following statements are True or False.

i) Unlike classes, structures cannot inherit other structures or classes.

ii) A structure can implement one or more interfaces.

iii) Structure members can be specified as abstract, virtual or protected.

A) i- True, ii- False, iii-True

B) i- False, ii- True, iii-True

C) i-True, ii-True, iii-False

D) i- False, ii- False, iii-True


Answers:

1.   C) i, ii and iv only
2.   B) System.ValueType
3.   D) All i, ii, iii and iv
4.   D) All i, ii, iii and iv
5.   A) i-d, ii-c, iii-a, iv-b
6.   A) 25
7.   B) Value Parameter
8.   A)<Access Specifier><Return Type> <Method Name> (parameter list) {Method body}
9.   D) All i, ii, iii
10. C) i-True, ii-True, iii-False


You Might also view the following Related Posts

Solved Objective Questions of C# set-1

0

1. Which of the following is not the component of .Net framework?

A) Common Language Run time(CLR)

B) .Net Framework Library.

C) Component Network

D) Windows Workflow Foundation (WF)


2. Following is/are the Integrated Development Environment (IDE) for C#.

A) Visual Studio 2010 (VS)

B) Visual Web Developer

C) Both A and B
Visual overview of the Common CLR Language Inf...
Visual overview of the Common CLR Language Infrastructure, and how the components relate to each other. Converted to SVG from PNG version, originally by Foofy from English Wikipedia. (Photo credit: Wikipedia)

D) Only A


3. A C# program may consist of the following parts.

i) Namespace declaration

ii) Class methods

iii) A main method

iv) Statement & Expressions

A) i, ii and iii only

B) ii, iii and iv only

C) i, iii and iv only

D) All i, ii, iii and iv


4. State True or False for naming class in C#.

i) The class name can be a C# keyword.

ii) A name must begin with a letter, can be followed by letters, digits and underscore.

A) i- True, ii- False

B) i- False, ii- True

C) i-True, ii-True

D) i- False, ii- False


5. ...................... is a name which can be used to identify a class, variable, function etc.

A) Keyword

B) Reference

C) Identifier

D) Object


6. .................... conversions are performed by C# compiler itself and ..................... conversions are performed by users by using predefined functions.

A) Implicit type, Explicit type

B) Explicit type, Implicit type

C) External type, Internal type

D) Internal type, External type


7. A variable can be declared by using which of the following syntax?

A) <variable_list> <data_type>;

B) <variable_list>, <data_type>

C) <data_type> <variable_list>

D) <data_type> <variable_list>;


8. Match the following.

i) *                  a) returns the address of an variable

ii) ? :                b) point to variable

iii) &                c) conditional expression

A) i-a, ii-b, iii-c

B) i-b, ii-c, iii-a

C) i-c, ii-a, iii-b

D) i-a, ii-c, iii-b


9. C# supports the following types of access specifiers.

i) public ii) friend iii) private iv) protected v) internal

A) i, ii, iii and iv only

B) i, iii, iv and v only

C) i, ii, iv and v only

D) All i, ii, iii, iv and v


10. ........................ access specifier allows a class to expose it's member variables and member functions to other functions and objects in the current application.

A) Internal

B) Protected

C) Private

D) Public


Answers:

1.  C) Component Network
2.  C) Both A and B
3.  D) All i, ii, iii  and iv
4.  B) i- False, ii- True
5.  C) Identifier
6.  A) Implicit type, Explicit type
7.  D) <data_type> <variable_list>;
8.  B) i-b, ii-c, iii-a
9.   B) i, iii, iv and v only
10. A) Internal


You Might also view the following Related Posts

How to write a program in C using for Loop?

0

For loop is the most popular looping structure in C programming language. It does required number of repetitions for the execution of block of codes. The For Loop allows us to specify three things about a loop in a single line, which are initialise counter, test counter and increment counter. Initialise counter sets a loop counter to an initial value, test counter test the loop counter to determine whether it's value has reached the number of repetitions desired and increment counter increase the value of loop counter each time the program segment within the loop has been executed. Here I have illustrated How to write a program in C using for Loop.

The general form of for statement is as follows.


for(initialise counter; test counter; increment counter)
{
block of codes
}


The diagram for the for loop is as follows.

write a program in C using for Loop
For-Loop

For example following is the program code in C to calculate simple interest. 


/*calculation of simple interest for 3 sets of p,n and r */
#include <stdio.h>
 int main()
{
int p,n,count;
float r,si;
for(count=1; count<=3; count=count+1)
 {
 printf("Enter values of p,n and r");
 scanf("%d %d%f", &p,&n,&r);
 si=p*n*r/100;
printf(simple interest=%f\n",si);
 }
 return 0;
 }


You can view the following other posts

Solved MCQ of C set-1

0

1. C language has been developed by
A) Martin Richards
B) Bijarne Stroustrup
C) Dennis Ritche
D) Ken Thompson

2. int[ ] ={5,6,7,8,9} What is the value of a[3]?
A) 9
B) 8
C) 7
D) 6


3. C can be used on
A) Only MS-Dos operating System
B) Only Linux operating system
C) Only Windows operating system
D) All of the above


4. Float a[15], what is the size of array?
A) 17
B) 14
C) 15
D) 16

5. C programs are converted into machine language with the help of
A) An Editor
B) A complier
C) An operating system
D) None of the above

6. Array is
A) Primary data type
B) Pointer data type
C) Heterogeneous data type
D) Homogenous data type

7. Which of the following is allowed in a C Arithmetic Instruction?
A) [ ]
B) { }
C) ( )
D) None of the above

8. To accept 100 different values into the array we require
A) Loop
B) If condition
C) Function
D) Structure

9. If a is an integer variable, a=7/3; will return a value
A) 2.5
B) 3
C) 0
D) 2

10. Pointer holds
A) Value of variable
B) Address of variable
C) Value and address of variable
D) Always null

Answers:
1. C) Dennis Ritche
2. B) 8
3. D) All of the above
4. C) 15
5. B) A complier
6. D) Homogenous data type
7. C) ( )
8. A) Loop
9. D) 2
10. B) Address of variable

You Might also view the following Related Posts

Solved MCQ of Java Set-1

0

1. Java programs are
A) Faster than others
B) Platform independent
C) Not reusable
D) Not scalable

2. Java has its origin in
A) C programming language
B) PERRL
C) COBOL
D) Oak programming language


3. Which one of the following is true for Java
A) Java is object oriented and interpreted
B) Java is efficient and faster than C
C) Java is the choice of everyone.
D) Java is not robust.


4. The command javac is used to
A) debug a java program
B) compile a java program
C) interpret a java program
D) execute a java program

5. Java servlets are an efficient and powerful solution for creating ………….. for the web.
A) Dynamic content
B) Static content
C) Hardware
D) Both a and b

6. Filters were officially introduced in the Servlet ……………… specification.
A) 2.1
B) 2.3
C) 2.2
D) 2.4

7. Which is the root class of all AWT events
A) java.awt.ActionEvent              
B) java.awt.AWTEvent
C) java.awt.event.AWTEvent
D) java.awt.event.Event

8. OOP features are
i) Increasing productivity                              ii) Reusability
iii) Decreasing maintenance cost               iv) High vulnerability
A) 1,2 & 4
B) 1,2 & 3
C) 1, 2 & 4
D) none of the above

9. break statement is used to
i) get out of method                                       ii) end aprogram
iii) get out of a loop                                         iv) get out of the system
A) 1 & 2
B) 1,2 & 3
C) 1 & 3
D) 3

10. Native – protocol pure Java converts ……….. into the ………… used by DBMSs directly.
A) JDBC calls, network protocol
B) ODBC class, network protocol
C) ODBC class, user call
D) JDBC calls, user call

Answers:
1. B) Platform independent
2. D) Oak programming language
3. A) Java is object ...... interpreted
4. B) compile a java program
5. A) Dynamic content
6. B) 2.3
7. B) java.awt.AWTEvent
8. B) 1,2 & 3
9. D) 3
10. A) JDBC calls, ......protocol

MCQ of C++ with answer Set-2

0

1. The ……………. Operator is known as insertion operator.
A) >>
B) >
C) <<
D) <

2. State True or False.
i) A satic function can have access to only other static members (functions or variables) declared in the same class.
ii) A static member function can be called using the class name (instead of its objects)
A) True, True
B) True, False
C) False, True
D) False, False

3. Which of the following condition is true for an object used as a function argument?
i) A copy of the entire objects is passed to the function.
ii) Only the address of the object is transferred to the function.
A) Only i
B) Only ii
C) Both i and ii
D) None of them


4. …………… enable us to hide, inside the object, both the data fields and the methods that act on that data.
A) Encapsulation
B) Polymorphism
C) Inheritance
D) Overloading

5. Which of the following is/ are the characteristics of friend function.
A) It is not in the scope of the class to which it has been declared as friend.
B) It can invoke like a normal function without the help of any object.
C) Usually, it has the objects as arguments.
D) All of the above.

6. The dereferencing operator ………….. is used to access a member when we use pointers to both the object and the member.
A) ->*
B) .*
C) Any of the above
D) None of the above

7. A ………………. Is a class whose instances themselves are classes.
A) Subclass
B) Abstract Class
C) Meta Class
D) Object Class

8. The dereferencing operator ……… is used when the object itself is used width in the member pointer.
A) ->*
B) .*
C) Any of the above
D) None of the above

9. A constructor that accepts no parameters is called the ……………….
A) Paramless constructor
B) No parameter constructor
C) Default constructor
D) Argumentless constructor

10. Automatic initialization of object is carried out using a special member function called …………
A) Friend
B) Casting
C) Reference Parameter
D) Constructor

11. Which of the following characteristics of constructor are true.
i) They should be declared in the public section.
ii) They are invoked automatically when the objects are created.
iii) They do not have return type and void also.
iv) We cannot refer their address.
v) Constructors cannot virtual.
A) Only i, ii, iii and v
B) Only ii, iii, iv, and v
C) Only i, iii, iv and v
D) All i, ii, iii, iv and v

12. A ……………. takes a reference to an object of the same class as itself as an argument.
A) Reference constructor
B) Copy Constructor
C) Self Constructor
D) None of the above

13. State True or False
i) A destructor never takes any argument nor does it return any value.
ii) It releases memory space for future use.
A) True, True
B) True, False
C) False, True
D) False, False

14. Which of the following operates cannot be overloaded?
i) Size of operator (sizeof)            ii) Scope resolution Operator
iii) Conditional operator (?:)        iv) Assignment Operator (=)
A) i, ii, iii only
B) ii, iii, iv only
C) i, iii, iv only
D) all i, ii, iii, iv

15. …………. Is the process of creating new classes, called derived classes from existing classes called base class.
A) Inheritance
B) Encapsulation
C) Polymorphism
D) Overloading

16. State True or False.
i) While overloading operators new operator can be overloaded.
ii) The binary operator such as +, -, * and must explicitly return a value.
A) True, True
B) True, False
C) False, True
D) False, False

17. ………… function writes a string of text to a window.
A) cputs ()
B) put ()
C) gets ()
D) tputs ()

18. Which of the following condition (s) should satisfy the casting operator.
i) It must be a class member.
ii) It must not satisfy a return type.
iii) It must have any arguments.
iv) All of the above.

19. Find the Hierarchy of Data Types.
i) Long double   ii) Double             iii) Float                                iv) Long                                v) Int         vi) Char
A) 1-2-3-4-5-6
B) 1-3-2-4-5-6
C) 1-2-3-5-4-6
D) 1-2-4-3-5-6

20. ………….. function sets the fill pattern and color.
A) floodfill ()
B) setcolor()
C) setfillstyle()
D) fillstyle ()

 Answers:
1.       C) <<
2.       B) True, False
3.       C) Both i and ii
4.       A) Encapsulation
5.       D) All of the above.
6.       A) ->*
7.       C) Meta Class
8.       B) .*
9.       C) Default constructor
10.   D) Constructor
11.   D) All i, ii, iii, iv and v
12.   B) Copy Constructor
13.   A) True, True
14.   A) i, ii, iii only
15.   A) Inheritance
16.   C) False, True
17.   A) cputs ()
18.   iv) All of the above.
19.   A) 1-2-3-4-5-6
20.   C) setfillstyle()


You might also view the following related posts
For other more posts: Click Here

Solved MCQ of C++ Set-1

0

1. C++ is an extension of C with a major addition of the class construct feature of ……………..
A) Simula67
B) Simula57
C) Simula47
D) Simula87

2. C++ has the name ………………….. before it was changed to C++.
A) Improved C  
B) Integrated C
C) C with classes
D) C with Simula

3. …………. Refer to the names of variables, functions, arrays, classes etc. created by the programmer.
A) Keywords
B) Identifiers
C) Constraints
D) Strings

4. In C++, the keyword void was used ………..
A) To specify the return type of function when it is not returning any value.
B) To indicate an empty argument list to a function.
C) To declare the generic pointers.
D) All of the above.

5. Match the following
a) : :                                       i) Pointer to member declarator
b) : :*                                    ii) Pointer to member operator
c) ->*                                    iii) Scope resolution operator
A) a-ii, b-iii, c-i
B) a-iii, b-i, c-ii
C) a-i b-ii, c-iii
D) a-iii, b-ii, c-i

6. If m and n are int type variables, what will be the result of the expression
m% n     when m=5 and n=2 ?
A) 0
B) 1
C) 2
D) None of the above

 7. Some of the C++ operators cannot overloaded which are
i) Member access operators (. And .*)                   ii) Conditional operator (? :)
iii) Scope resolution operator (: :)                             iv) Size operator (sizeof)
A) only i, ii and iii
B) only ii, iii and iv
C) only ii and iv
D) All i, ii, iii and iv

8. Some of the situations where inline expansion may not work are:
A) For functions returning values, if a loop, a switch or goto exists.
B) If functions contain static variables and they are re-cursive.
C) For functions not returning values, if return statement exist.
D) All of the above.

9. Which of the following control expressions are valid for an if statement?
A) an integer expression
B) a Boolean expression
C) either A or B
D) Neither A nor B

10. …………… is a way to bind the data and its associated functions together which allows the data and functions to be hidden.
A) Structure
B) Class
C) Enum
D) Both A and B

Answers

1. A) Simula67
2.   C) C with classes
3.   B) Identifiers
4.  D) All of the above.
5.   B) ii-False, ii-True
6.   B) 1
7.  D) All i, ii, iii and iv
8.  D) All of the above.
9.   B) a Boolean expression
10.  B) Class

Programming Language Definition

0

Programming Language Definition: A sequence of instructions that a computer can interpret and execute to complete task is called computer program. The language which is used to develop a computer program is called programming language. There are two types of programming language which are procedure oriented programming language and object oriented programming language.
1.       Procedure Oriented programming:Conventional programming, using high level languages such as COBOL, FORTAN and C is commonly known as procedure oriented programming (POP). In the procedure oriented approach, the problem is viewed as a sequence of things to be done such as reading, calculating and printing. Procedure oriented programming basically consists of writing a list of instructions (or actions) for the computer to flow and organizing these instructions into groups known as functions.

Characteristics of Procedure Oriented Programming
i)        Emphasis is on doing things (algorithms)
ii)       Large Programs are divided into smaller Programs Known as functions.
iii)     Most of the functions share global data
iv)     Data move openly around the system from function to function.
v)      Functions transform data from one to another.
vi)     Employs top-down approach in program design.

Drawbacks of Procedure Oriented Programming
i)        In large program it is very difficult to identify what data is used by which function. In case we need to revise an external data structure, we also need to revise all functions that access the data. This provides an Opportunity for bugs to creep in.
ii)       With the procedural approach is that it does not model real world problems very well. This is because functions are action oriented and do not really corresponding to the elements of the problem.

2.       Object-oriented Programming: Object oriented programming treats data as a critical element in the program development and does not allow it to flow freely around the system. It ties data more closely to the functions that operate on it, and protects it from accidental modification from outside functions. OOP allows decomposition of a problem into a number of entities called objects and then builds data and functions around these objects.

Characteristics of Object-Oriented programming
i)        Emphasis is on data rather than procedure.
ii)       Programs are divided into what are known as objects.
iii)     Data structures are designed such that they characterize the objects.
iv)     Functions that operate on the data of an object are tied together on the data structure.
v)      Data is hidden and cannot be accessed by external functions.
vi)     Objects may communicate with each other through functions.
vii)   New data and functions can be easily added whenever necessary. Follows bottom up approach is program design.

Benefits of Object Oriented Programming
i)        Through inheritance we can eliminate redundant code and extend the use of existing classes.
ii)       We can build programs from the standard working modules that communicate with one another, rather than having to start writing the code from scratch. This leads to saving of development time and higher productivity.
iii)     The principle of data hiding helps the programmer to build secure programs that cannot be invaded by code in other parts of the program.

Some terms used in Object Oriented Programming

Ø  Objects: Objects are basic run-time entities in an object oriented system.
Ø  Classes: A class is a collection of objects of similar type.
Ø  Data Abstraction and Encapsulation: The wrapping up of data and functions into a single unit is known as encapsulation.
Abstraction refers to the act of representing essential features to the act of representing essential features without including the background or explanations.
Ø  Inheritance: Inheritance is the process by which objects of one class acquire the properties of objects of another class.
Ø  Polymorphism: Polymorphism is another important OOP concept. Polymorphism, a Greek term means the ability to take more than one form. The operation may exhibit different instances the behavior depends upon the types of data is the operation.
Ø  Dynamic Binding: Binding refers to the linking of a procedure call to the code to be executed in response to the call. Dynamic binding (also known as late binding) means that the code associated with a given procedure call is not known until the time of the call at run time.
Ø  Message passing: A message for an object is a request for execution of a procedure and therefore will invoke a function (procedure) in the receiving object that generates the desired result.
 


يتم التشغيل بواسطة Blogger.