Sunteți pe pagina 1din 13

2/25/2015

C# Questions & Answers - Properties and its Applications | Sanfoundry

Home

About

Jobs

Contact

C-Tutorials

Courses | Fees | Dates

C-MCQs

Computer-Science-MCQs

C++MCQs

College-Projects

Java-MCQs

C-Programs

C#MCQs

Testimonials

Linux-MCQs

Internship

Developers

SAN-MCQs

Best-Books

C# Questions & Answers


Properties and its Applications

SAN I - Technology Training

Advertisements

THERE WILL BE
HATERS

Best Training
Courses
SAN II - Administration Training
Linux Fundamentals/Administration

Hover to Expand

Advanced C Programming
Linux-C Debugging Techniques
Linux System Programming

This section of our 1000+ C# multiple choice questions focuses on


properties and its application in C# Programming Language.

Linux IPCs Programming


Linux Network Programming
Linux Multithreaded Programming

1. Correct way to implement a read only property add in a math class?


a)

Linux Kernel Programming


Linux Kernel Debugging
Advertise Here

1.

class math

2.

Device Driver
Trainings

3.

int ad;

4.

public int add

Linux Device Drivers Basics

5.

Linux Block Device Drivers

6.

get

Linux Network Device Drivers

7.

Linux PCI Device Drivers

8.

return ad;

9.

10.

Linux Video Device Drivers


Linux Audio Device Drivers

Linux I2C Device Drivers

11.
12.

Linux USB Device Drivers

Advertisements

b)

1.

class math

2.

3.

public int add

4.

5.

get

6.

http://www.sanfoundry.com/csharp-mcqs-properties-applications/

1/13

2/25/2015

6.

C# Questions & Answers - Properties and its Applications | Sanfoundry

7.

return ad;

8.

9.
10.

}
}

c)

1.

class math

2.

3.

int ad;

4.

public int add

5.

6.

get

7.

8.

return ad;

9.

10.

set

11.

12.

ad = value;

13.

14.
15.

}
}

Technical Career

d) None of the mentioned

Developer Tracks

View Answer

SAN Developer

2. Correct way to implement a write only property add in a math class?

Linux System Developer

a)

Linux Kernel/Driver Developer


Linux Network Developer

1.

class math

2.

Mentoring
Productivity

3.

public int add

4.

GDB Assignment
Feedback

5.

set

6.

Advertisements

7.

add = value;

8.

9.
10.

Coding-Style

}
}

b)

1.

class math

http://www.sanfoundry.com/csharp-mcqs-properties-applications/

2/13

2/25/2015

1.

class math

2.

C# Questions & Answers - Properties and its Applications | Sanfoundry

3.

int ad;

4.

public int add

5.

6.

set

7.

8.

ad = value;

9.

10.

11.

1000 C# MCQs |
Quiz
Integer Data Types
Floating and Decimal Data Types
Char Types and String Literals
Initialization of Variables

c)

Scope and Lifetime of Variables


Type Conversion in Expressions

1.

class math

Arithmetic Operators

2.

Relational and Logical Operators

3.

int ad;

Bit-wise and Conditional Operators

4.

public int add

IF Statements

5.

Switch Statements

6.

get

For Loop Statements

7.

While Loop Statements

8.

return ad;

Do While Loop Statements

Continue, Goto statements

10.

set

Fundamentals of Class

11.

Reference Variables and Assignment

9.

12.

ad = value;

13.

14.

15.

Methods in Class
Constructors in Class
Destructors in Class
Array and Initialization
Basic Operation on Strings
String Class with Description
Comparison of Strings

d) None of the mentioned


View Answer

Searching and Modifying Strings


Operation on Characters
Public & Private Access Modifier

3. Select the correct statement about properties in C#.NET?


a) A property can simultaneously be read or write only
b) A property can be either read only or write only
c) A write only property will have only get accessor
d) A read only property will have only get accessor
View Answer

Use of Ref and Out Parameters


Use of Variable Arguements
Polymorphism
Structures
Enumerations
Fundamentals of Inheritance
Inheritance Implementation

4. What will be the output of following snippet of code?

Method Overloading
Method Overriding

1.

class number

2.

3.

private int num1;

http://www.sanfoundry.com/csharp-mcqs-properties-applications/

Constructor Overloading
Abstract Class & Methods
Introduction of Overloaded Operators
Recursion
3/13

2/25/2015

C# Questions & Answers - Properties and its Applications | Sanfoundry

4.

private int num2;

5.

public int anumber

6.

Recursion

Introduction of Indexers
Introduction of Properties
Properties and its Applications

7.

get

8.

9.

Interfaces Introduction
Interfaces Implementation

return num1;

Fundamentals of Exception Handling

10.

Implementation of Exception Handling

11.

set

Exceptions of Type Finally and Built in

12.

Try & Catch in Detail

13.

num1 = value;

14.

Attributes
Introduction of Console I/O Operations

15.

Reading Console Input Operations

16.

public int anumber1

Writing Console Output Operations

17.

Introduction of Stream Classes

18.

get

19.

20.

Byte Stream
Character Stream

return num2;

21.

22.

set

23.

24.

Fundamental of Generics

26.

Delegates in Detail
Events

num2 = value;

25.

Fundamental of Delegates

Generic Methods
Fundamental of LINQ
Operation and Query with LINQ
Introduction of Reflections

27.

Collection Classes

28.

class Program

Maths Class

29.

Rounding Functions in C#

30.

public static void Main(string[] args)

Math Methods

31.

Multi-threaded Programming - 1

32.

number p = new number();

Multi-threaded Programming - 2

33.

p.anumber = 20;

Iterators

34.

number k = new number();

Fundamentals of Namespaces

35.

k.anumber1 = 40;

Fundamentals of Preprocessors

36.

int m = p.anumber;

Method with Parameters

37.

int t = k.anumber1;

Fundamental of Networking

38.

int r = p.anumber + k.anumber1;

URI class

39.

Console.WriteLine("number = " +m);

Network Errors Handling

40.

Console.WriteLine("number = " +t);

41.

Console.WriteLine("sum = " +r);

42.

Console.ReadLine();

43.
44.

}
}

Type Interface
Unsafe Code & Pointers Basics
Pointers Operation - 1
Pointers Operation - 2
Accessor Controls of Class
Introduction of String Formatting
String Formatting - 1

a) 0
b) Compile time error
c) 60
d) None of the above mentioned
View Answer
http://www.sanfoundry.com/csharp-mcqs-properties-applications/

String Formatting - 2

Follow Manish & Sanfoundry


Follow

1.2k
4/13

2/25/2015

C# Questions & Answers - Properties and its Applications | Sanfoundry

View Answer

5. What will be the output of following snippet of code?


Follow

1.

class number

2.

Subscribe to Sanfoundry

3.

private int num1 = 60;

4.

private int num2 = 20;

5.

public int anumber

6.

7.

get

8.

9.

return num1;

10.

11.

set

12.

13.

num1 = value;

14.

15.

16.

public int anumber1

17.

18.

get

19.

20.

return num2;

21.

22.

set

23.

24.

num2 = value;

25.

26.

27.

28.

class Program

29.

30.

public static void Main(string[] args)

31.

32.

number p = new number();

33.

number k = new number();

34.

int m = p.anumber;

35.

int t = k.anumber1;

36.

int r = p.anumber * k.anumber1;

37.

Console.WriteLine("sum = " + r);

38.

Console.ReadLine();

39.
40.

1.5k

}
}

a) 0
http://www.sanfoundry.com/csharp-mcqs-properties-applications/

5/13

2/25/2015

C# Questions & Answers - Properties and its Applications | Sanfoundry

b) 120
c) 1200
d) Compile time error
View Answer
6. What will be the output of following snippet of code?
1.

class number

2.

3.

int length = 50;

4.

public int number1

5.

6.

get

7.

8.

return length;

9.

10.

set

11.

12.

length = value;

13.

14.

15.

16.

class Program

17.

18.

public static void Main(string[] args)

19.

20.

number p = new number();

21.

p.number1 = p.number1 + 40;

22.

int k = p.number1 * 3 / 9;

23.

Console.WriteLine(k);

24.

Console.ReadLine();

25.
26.

}
}

a) 0
b) 180
c) 30
d) Compile time error
View Answer
7. What will be the output of following snippet of code?
1.

class number

2.

3.

int length = 60;

4.

public int number1

http://www.sanfoundry.com/csharp-mcqs-properties-applications/

6/13

2/25/2015

C# Questions & Answers - Properties and its Applications | Sanfoundry

4.

public int number1

5.

6.

get

7.

8.

return length;

9.

10.

11.

12.

class Program

13.

14.

public static void Main(string[] args)

15.

16.

number p = new number();

17.

int l;

18.

l = p.number1 + 40;

19.

int k = l * 3 / 4;

20.

Console.WriteLine(k);

21.

Console.ReadLine();

22.
23.

}
}

a) 30
b) 75
c) 80
d) 0
View Answer
8. What will be the output of following snippet of code?

1.

class student

2.

3.

int []scores = new int[5] {23, 42, 54, 11, 65};

4.

public int this[int index]

5.

6.

get

7.

8.

if (index < 5)

9.

return scores[index];

10.

else

11.

12.

Console.WriteLine("invalid index");

13.

return 0;

14.

15.

16.

set

17.

http://www.sanfoundry.com/csharp-mcqs-properties-applications/

7/13

2/25/2015

C# Questions & Answers - Properties and its Applications | Sanfoundry

18.

if (index < 5)

19.

scores[index] = value;

20.

else

21.

Console.WriteLine("invalid index");

22.

23.

24.

25.

class Program

26.

27.

public static void Main(string[] args)

28.

29.

student s = new student();

30.

Console.WriteLine(s[4] + 8);

31.

Console.ReadLine();

32.

33.

a) 73
b) 37
c) 0
d) Run time error
View Answer
9. Correct way to implement the property for which property reports the
error invalid index if user attempts to cross bounds of the array for a
student class with 5 intger arrays.
a)
1.

class student

2.

3.

int []scores = new int[5] {23, 42, 54, 11, 65};

4.

public int this[int index]

5.

6.

get

7.

8.

if (index < 5)

9.

return scores[index];

10.

else

11.

12.

Console.WriteLine("invalid index");

13.

return 0;

14.

15.

16.

set

17.

18.

if (index < 5)

19.

scores[index] = value;

20.

else

http://www.sanfoundry.com/csharp-mcqs-properties-applications/

8/13

2/25/2015

C# Questions & Answers - Properties and its Applications | Sanfoundry

20.

else

21.

Console.WriteLine("invalid index");

22.

23.
24.

}
}

b)

1.

class student

2.

3.

int []scores = new int[5] {23, 42, 54, 11, 65};

4.

public int this[int index]

5.

6.

get

7.

8.

if (index < 5)

9.

return scores[index];

10.

else

11.

12.

Console.WriteLine("invalid index");

13.

return 0;

14.

15.

16.
17.

}
}

c)

1.

class student

2.

3.

int []scores = new int[5]{23, 42, 54, 11, 65};

4.

public int this[int index]

5.

6.

set

7.

8.

if (index < 5)

9.

return scores[index];

10.

else

11.

12.

Console.WriteLine("invalid index");

13.

return 0;

14.

15.

16.
17.

}
}

http://www.sanfoundry.com/csharp-mcqs-properties-applications/

9/13

2/25/2015

17.

C# Questions & Answers - Properties and its Applications | Sanfoundry

d) None of the above mentioned


View Answer
10. What will be the output of following snippet of code?
1.

class student

2.

3.

int []scores = new int[3] {13, 32, 24};

4.

public int this[int index]

5.

6.

get

7.

8.

if (index < 3)

9.

return scores[index];

10.

else

11.

12.

Console.WriteLine("invalid index");

13.

return 0;

14.

15.

16.

private

17.

set

18.

if (index < 3)

19.

scores[index] = value;

20.

else

21.

Console.WriteLine("invalid index");

22.

23.

24.

25.

class Program

26.

27.

public static void Main(string[] args)

28.

29.

student s = new student();

30.

int[] scores1 = new int[3] {8, 19, 40};

31.

for (int i = 0; i < 3; i++)

32.

33.

if (scores1[i] > s[i])

34.

35.

Console.WriteLine(" scores1 had greater value :" + scores1[i]);

36.

37.

else

38.

39.
40.

Console.WriteLine("scores had greater value :" + s[i]);


}

http://www.sanfoundry.com/csharp-mcqs-properties-applications/

10/13

2/25/2015

40.

C# Questions & Answers - Properties and its Applications | Sanfoundry

41.

42.

Console.ReadLine();

43.
44.

}
}

a) 0
b) Compile time error
c) Run time error
d) scores had greater value : 13
scores had greater value : 32
scores1 had greater value : 40
View Answer
Sanfoundry Global Education & Learning Series C# Programming
Language.
Heres the list of Best Reference Books in C# Programming Language.
To practice all features of C# programming language, here is complete
set on 1000+ Multiple Choice Questions and Answers on C#

0
Tweet

Advertisements

THERE WILL BE HATERS


Hover to Expand

Subscribe Newsletter & Posts


Name

*
Email Address
http://www.sanfoundry.com/csharp-mcqs-properties-applications/

11/13

2/25/2015

C# Questions & Answers - Properties and its Applications | Sanfoundry

*
Subscribe

Read Next:
1. C# Program to Demonstrate Properties of the Class
2. C# Questions & Answers Introduction of Properties
3. C# Questions & Answers Introduction of Indexers
4. Python Questions and Answers Files 1
5. C# Questions & Answers Implementation of Exception
Handling

Manish Bhojasia, a technology veteran with 17+ years @ Cisco &


Wipro, is Founder and CTO at Sanfoundry. He is Linux Kernel
Developer

and SAN

Architect and

is passionate

about

competency developments in these areas. He lives in Bangalore


and delivers focused training sessions to IT professionals in Linux
Kernel, Linux Debugging, Linux Device Drivers, Linux
Networking, Linux Storage & Cluster Administration, Advanced C
Programming, SAN Storage Technologies, SCSI Internals and
Storage Protocols such as iSCSI & Fiber Channel. Stay
connected with him below.

Manish Bhojasia
Follow
1,289 followers

Sanfoundry
Follow

+1

+ 1,539

http://www.sanfoundry.com/csharp-mcqs-properties-applications/

12/13

2/25/2015

C# Questions & Answers - Properties and its Applications | Sanfoundry

Practice Interview Questions & Answers, Quizzes, Objective,


Multiple Choice Aptitude Tests for Freshers and Experienced
People in these topics C, C++, C#, Java, Linux, SAN, Javascript, PHP, Python
Operating Systems, Computer Organization and
Architecture, Database Management Systems, Software
Architecture & Design, Software Engineering, Artificial
Intelligence, LISP Programming, Computer Networks,
Microprocessors
Learn C, C++, Java and C# Programming with coding example
on Simple problems as well as tough Algorithms and Datastructures along with runtime output: - C Programs, DataStructures and Algorithms, C++ Algorithms, Java Algorithms, C#
Programs, Android Programs in Java
C Tutorials and Linux Commands Tutorial - C Tutorials, Linux
Commands
Career Mentoring with our Founder / CTO - Read More

Terms of Use & Privacy Policy


Interns
Jobs
Sitemap

Copyright

Technology Groups

Sanfoundry is No. 1 choice for Deep Hands-ON Trainings in SAN, Linux & C, Kernel & Device Driver Programming. Our Founder has trained
employees of almost all Top Companies in India. Here are few of them: VMware, Citrix, Oracle, Motorola, Ericsson, Aricent, HP, Intuit, Microsoft,
Cisco, SAP Labs, Siemens, Symantec, Redhat, Chelsio, Cavium Networks, ST Microelectronics, Samsung, LG-Soft, Wipro, TCS, HCL, IBM,
Accenture, HSBC, Northwest Bank, Mphasis, Tata Elxsi, Tata Communications, Mindtree, Cognizant, mid size IT companies and many Startups.
Students from top Universities and colleges such as NIT Trichy, BITS Pilani, University of California, Irvine, University of Texas, Austin & PESIT
Bangalore have benefited a lot from these courses as well. The assignments and real time projects for our courses are of extremely high quality
with excellent learning curve.
Register for Expert Level Training Classes by our Founder & CTO. Alternatively, call us for your Corporate Training or College Training
needs.
Responsive Theme powered by
2015 Sanfoundry

WordPress

http://www.sanfoundry.com/csharp-mcqs-properties-applications/

13/13

S-ar putea să vă placă și