Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
100%
(2)
100% found this document useful (2 votes)
3K views
132 pages
Dot Net Solution BCA MDu
That is a sample paper of suman vadwha for those Student MDu university and affilation collages . Dot Net SumanWadwha
Uploaded by
Jai Rathor
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Download
Save
Save Dot Net Solution BCA MDu For Later
Share
100%
100% found this document useful, undefined
0%
, undefined
Print
Embed
Report
100%
(2)
100% found this document useful (2 votes)
3K views
132 pages
Dot Net Solution BCA MDu
That is a sample paper of suman vadwha for those Student MDu university and affilation collages . Dot Net SumanWadwha
Uploaded by
Jai Rathor
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Carousel Previous
Carousel Next
Download
Save
Save Dot Net Solution BCA MDu For Later
Share
100%
100% found this document useful, undefined
0%
, undefined
Print
Embed
Report
Download
Save Dot Net Solution BCA MDu For Later
You are on page 1
/ 132
Search
Fullscreen
www.lMVduQuestionPaper.in www.TechbrHindi.com Next Semester 4 Latest Papers Waa Weel Download Het H fre 3g eat Whatsapp Sif =t Wad & Whatsapp No : 8076723805 Email :
[email protected]
wistofSelected Questions 16 18 ADHVIA's Selected Questions and Answers 4p What is exception handling? What. ace ine _ different blocks that C# uses to handle the SSS aS om esa? 1.1 Discuss whether Ci ineropesabie wr noe HBr Tare acnaea, Cradle MDURCA BE 2017 implemented in C#? MDU BCA RE 2037, 2017 oR pe Explain Interface. ‘MDU BCA RE 2015 eo ~Buages, oe REGIS P S, which defines 5 ee sevol lesa: (Gay erguoge ia the NET femeuone What do you understand by Interfaces in CH? | hs 1 REY rogram cin ue ene COM What are the characteristics of an Interface orth angaiertey ac eee Mlustrate the implementation of Interfaces i Q AG allied as type safe language? es : MDUBCA 2018 21.(b) Explain automatic memory management. on Discuss whether Ci fstype safe or not? MDUBCARE20I§ — (\~ BS oO MDU BCA 2017 What do you mean by automatic memory ARS. CW is type safe. The Common Type System provides | type safety, which in tur improves, ode subliny Ce ' Drovies the fellowing type safety measure. management? How itis performed in C MDU BCARK. or + One cannot use uninitialized variables What do you mean by ani femory | +H enforces overflow checking in arithmetic Explain. inced features of MDU BCA 2013 management in C# ? How.i operations, + Ue checks the range of an array and warns wlien the aecess Roes out of bound. + Dynamically allocated objects and arrass are initialized to zero, + L supports ancomatie garbage collection. Le) Explain in detail Ch. Q1.3 Discuss whether C# supports versioning or not? ina Ans. Versioning is the pracess of evolving an api {compitible manner. C¥ suppors both source (oh,Indispensable to aecornplish the task. Microso%t “developed NET integrating “web services’ and he software fr implementing and dcivering hese services is 9 software framework thot intcytcs presentation technologies, components. technolo Ieeiologis ona singe platform s0 ast enable users to Gevelop intemet applications exsily. NET software Strategy includes thee main approaches which ste © Microsoft NET Platform Microsoft NET Products and Services ‘Thitd-party NET ServicesINTRODUCTION TO NET. a WADHWA’s Selected Questions and Answers 24 Microsoft NET N eS : x 4 SS Microsoft NET Strategy Be Microsoft NET Platform Microsoft NET Products and Services ‘The NET Platform ‘The NET platform provides for easier use of compu! i.e, Quicker and easier access to necessary applicetions unfailing communication and better security CNET platform defines core services such as 9 (ype. ‘gysiem as well as @ wealth of libraries Microsoft NET platform includes components + NET infrastructure and tools + NET user experience NET building block + NET device software QU7 What does the NET slggan “be there WI are” mean? Ans. One ofthe mist important benefis of NET approach © | Fee er angorges iio ve naar: | a ies we yon at — meme te existing language shat supports Common Langage Speciation for wring NET programs. This ik cuit great news othe programmer community beat ey en use their favorite language to develop NET applications Q1.8 What is Common Type System? MDU BCA RE 2018 MDUBCA RE 216 oR Explain CTS. oR What is CTS? For what purpose it is used? ‘Ans. An interesting aspect of the NET platform is that the types are independent of the language in which the source code is written, The NET achieves the language exchange ability by Sharing a common data type system with all the languages. This shared date type is known as Canunan aa ‘System (CTS), as FS is used to Facilitate cross-language integration, type safety, and high performance code execution. + Define the rules by which all pes are declared, defined and managed, regardless of source language. Q1.9 Why NET? ‘Ans. NET was crafied by Mictosoft to make software developers more productive. Key to this productivity was providing a set of tools and technologies thar hs the inherent complexities of waditonal sofa development and makes them avaiable through ante ——a Ef one is .NET Framework? ‘Ans. .NET framework is a complete environment that allows ‘evelopers to develop, run andi dept following, applications + Consote applications + Windows Forms applications + Windows Presemation Founstation applications Web applications (ASP.NET applications) Web Services1NTRODUCTION TO NET 24 WADHW LTE EN 's Selected Questions and Answers 25 «Windows Services QLAG Ditterensiste between COM and OLE Service-oriented applications using Windows techooloss. ‘MDU BCS RE 2087, 2017, Corumunication Foundation (WCF) Workflew-enabied applications using Windows Workflow Foundations (WWF) NET Framework also enstiss a Sevclope: 0 create ‘Gaarable components to be Used in distributed computiog achiecure NET Fraimeeork suppoas the object ‘jienecd programming mode} for multiple languages, Goch a Visual basic, Vicwal C# and Visual C++, NET Feamre-ck soppors multiple programming languages it a same that allows langage itecoperability, This Ans. Follos! sme (CUR) is the age Bat ‘= execution tine. Besige imeroperabiliy, an essenal ‘Since all languages must use the same ‘Location and visibility: A private assembly is normally ied by a single application, and is stored in the application's directory, or a subilirectory beneath. A ed assenibly is normally stored in the Global sembly Cache (GAC), which is repository of Semblics maintained by the NET runtime, Shared assemblies are usually libraries of code which many applications ili find useful, eg, the NET framework classesINTRODUCTION TO NET 28 WADHWA’s Selected Questions and Answers Versioning: The runtime enforces versioning constraint fi e s file, where all this information is corporsted into a Gay on sard atcenblics nt ca pause sen : | finde DLL or EXE taser rl ao eae Ea ests eager infomation W incoporid no spew BL tek Si re eae trpncs les sd # mantle One af eek MDUNCA RE ante Aor fat SeRbly i tro ency ree es latter ppg pens Om cx ee rteraces ead sc. Thos fon af eae new objects and it automatically will delete them, when are the following: + It forms @ security boundary. An assembly te the In the NET Framework, there is a special component of unit at whieh permissions. are requested and the CLR (Common Language Runtime) that looks after granted. 4 ‘memory management. It is called a “garbage collector” ; ne ‘ 8 | + Mt forms a type boundary. Every pe's ilenty eowomated meinory clenning system). The garbage | includes, the name of the assembly in which it collector has the following main tasks: 10 check when the eee Allocaied memory for varables-is no longer in use, 10 felease it and make it available for allocation of new + Ieforms a reference seope boundary, The assembly's a. ‘manifest contains assembly metadata thais used for ‘resolving pes and. resource requests. “Ch has at its core a precise memory management scheme Fe heat ne ees um + Ie forms a version boundary. The assembly is the pr ers have 0 write less code. Automatic inalest ersionable Oat ate fsmanagement policies ore carried cut by the canine: ot Or eo eae ge collector, and these policies mean that the eer does not have to manually allocate and free 1 is the nie at which supported. Two with diferent versions applications that depend on « specify assembly ofthat ves various functions of an assembly. ws ale organized and packaged into code executed by the NET runtime must 1 an assembly. The assembly contains the da manifest needed (0 can the blies can be organized into a singleWADHWA's Selected Qui INTRODUCTION TO_NET 30 : se NET buse classes are in) a namespace ex, 1.23 What is C#? MDU BCA RE 2018 purpose i Qi23 What Ce MOUBCA System, The base class Array is in the namespace, so ‘Ans. Cis « new language designed hy Miciosoft to work with ri asaeld SyecereA eee the .NET framework, In their “Inoduction to C#" - whitepaper, Microsoft describes CW 0s follows. Q1.26 What is default value? MDU BCA RE 2; “Ch isa simple, modern, abject oriented and pesafe programming lariguage derived from C and Cas. C# is Explain default waite MDU BCA 201 Firmly plasted in the C end Ce+ family wee of ai peepee Reo ena oC Cor ‘Ans, In Ce, a reel) sighed a value before bein; Prograruners. C¥ eims to combine the high productivity 1 fogrammer does mot assign Se C# compiler automatical Of Visual Basic and the raw power of Ce.” x “ae ‘The default value of a variable i, Q1.24 What are constructors in C#2 RE 201 AMSA constractor can be defined ax method which is a abjects of the class § oa 1s spc meme mei becas @& ate ess preemies 20 att Ise when it is created. This i: ‘suromatic decimal type “ntalization of objects. eae " nat (QU.25 What are nam: x00 false bool type chum pe that NET avoids neme clashes Allreferenes types A namespace 1s) fore than a grouping of dsta types bu has the effect hat he ames ofall datatypes within » 127 famespace re automatically prefixed with the name of Gg one rated the namespace Mis also possible to next mimespaces Within exch other For-exsinple, mest of the gence! fined data types C# has? 1 15 predefined a < ? data types. Out of theseINTRODUCTION TO .NET _ cS QL28Should Boxing and Unboxing operations be ‘Ans, Boring and unboxing operation: jt Eight data types represent integers: byte, sbyte, short, short, int, wits, long and wlone > Two data types represent Moating point numbers ‘float, double = Onedala type represents boolean valves: bool ‘+ One data type represents characters: char One data type represents dec ‘= One data type represents strings: string ‘+ And one of them represents objects: object preferred? expensive in terms of resources and overhead, so one should try to avoid them whenever possible and ensure that one should the correct type (0 solve the problem = interfaces in C#? MDU OR Explain Interfaces. ‘Ans. C# does not suppor lentance, But it can not ‘over Jook the benei inhentane: Therefore inorder to enjoy the benefits of multiple inheritance, Ci provides inceriaces methods defined in an interfac mentation and they only specify the parameters: ec and the types of als they will rm. AB {is always implemented in a class, The class menting the interface guarantees to provide an of all the methods declared in the .e do fot have their we WADHWA’s Selected Questions and Answers 49 it and Answers 33, QU30 What are .NET building block services and how. these provide strength {0 the NET framework? MDU BCA RE 2017, 2017 ‘Ans, The building block’ services area set of XML Web Services that are used to move control of user data between various applicayjayfWnd users. They enable verona, sombsie GB Wsseney sco he various appl ices, and devices while urge sy coaen ie ihe baer ana O So NT evs at Ment ter ede NET Pasport and NET Ales. NET Pee slows se sgl name nd pl al eb Sic tat sipped Psp sibenicaion. NET Ale thar comune wih Ire Spends inoonaton. Tht Micrsot NET proves, We serces to consumers 10 lp them sey ange thet peon infomation “one wie lms auentcaton and ata management series 10 companies. Micvst wil offers few bwin Host Serces i aes tate cal oh nani of INET Frmewor: a wie tnge ol puto and evelopes ae expected to sgn expand et of bung lockseniees QU31 What js Dummy Class? Ans. A class with no member is a alld elas a is own as dummy class or empty class. For example!‘Public void message(char ch) (... public void message(sting msg) (:..) Public Void message(string msg, int val) (...) Publi void messaye(string ms, int a, int b)(. Q1.34 What do you mean by read only members in cH MDU BCA 2017 Ans. For data’ members that must not be modified, the readonly Keywor! is provided by CH. It achieves the objective of preventing the value as member from being changed after it hasINTRODUCTION TO NET 36 | WADHWA's Selected Questions and Answers 37 ‘The readonly member varia are closely related to the ed 0 th QU.35 What do you mean by static members in CH?" eenstant data member, but holds an important difference | = fe cowait mene’ vale Is tt ihe vate | MDUBCARE 2017 specified in the source code when the program is | Ans. Stat gram is} AMS. Statie members are the fields an Bmpiled and represents this value throughout the ife- | peer ie eo leg Ue ee Reeeebie Ccdrislied pfaprarn. Ta‘eontrash the readonly object. The other distinctive ember is assigned ils value when an object is created are and only Keeps this value during the lifedime of the oS \ + Static members can be aece: objects created. Cppeelds fields or instance fields When they are declared. as fnstence fields, they can take different values. with Static: members AE for situations here the the objects or when ane wants ‘without creating abject class Test ps) ‘ ghos ve ocd eee { Bes ole ela mea ee different objects. Consider the code below. member is Co moieties gol Less aie sae Jnl ame me A QQ Ramana i Fe Q1.36 Explain the differences between managed and ) cs unmanaged code? ‘Ans. Managed code 1s the code that is execured directly by ' Beeieaie ne provided tno Te of erin ‘object using the constructor with parameter & ‘will remain constant for that object lr of creation of an the CLR instead of the operating system. Unmanaed is value code i the code that is executed directly by the operating system outside the CLR envirommich be‘pplications include: + Windows applications Console applications Creating Web controls Providing Web services Developing NET component library Developing windows controls Developing ASP.NET projects ots used to obiin the size Cin byte) of of operator can be applied only t0cs 0 INTRODUCTION TO..NET ie Qi40 How automat ‘out with C#? memory management is carried ‘Ans C# provides automatic memory management Essentially, xt allocates a portion of memory as and ‘when zequized. When mesoty is short, it looks for areas that are no loager referenced, These areas of memory are then freed up (leallocated) so that they can be reallocated. This process is often referred to as “garbage collection" ‘The CLR aintime uses an approach known as mark und sweep lo weviify objects which can be freed up, The ‘garbage collection process searches from any root objects, 1. objects (om Which the main method has been sun, marking all the objects it finds. It th: examines all the objects currently held in memory and deletes those objects that are not marked. IC is at this ‘point that an object's destaietor method is exceuted. “Thus, automatic memory management policies are aried out by the garbage collector, and these policies ‘that the programmer does not have to manually locate and free memory used by objects. is the general lifecycle of an object: is now live. no tonger in use, it needs | WADHWA's Selected Questions and Answers at MEDI Selected Qusetions ane Anavars at 6 Pinalizers are run (unless overridden), 7 The object ts now inaccessible and is available for ‘he garbage collector to carry ott clean-up. 8 The garbage collector frees up associated memory. QL41 What are the characteristics of an abstract class? Ans. ‘The following are some of the distinct characteristics of an abstract class: } + One cannoe instantiate an abstract class directly. This means that one can not create an object of the abstract class, it must be inherited. One can have abstract as well ax non-abstract ‘members in an abstract class + An abstract class can only he used a the base class of another class + Amabsiract class is always public QL42 What are the services provided by Common. Language Runtime? Ans. Following are the services provided by Common Language Runtime: + Memory management + Loading ond execution of programs © Enforcing security policy . . String panting ra adress + Hanaling exceptions + tateroperablty with o A ahh6 Development of applications 7. ASPNET- center of web application development ‘everything appears im the eontext of an object. ‘One of the greatest changes to Web application development in the Microsoft world is NET's use of vas Visual Basic NET Users and. A¢ = ean now establish: secuniy rules for different NET femtures to limit. alicia programs from doing their damage, .NET’s also support strong data typing and garbage collectionINTRODUCTION TO .NET 4 ———— ET 5, Developer productivity through standards The NET Framework is built upon and uses man and existing standards, such as XML and SOAP (Simple Object Access Protocol), This enhances data interchange not only on the Windows platform, but also in interactions with other platforms and systems. 6. Development of applications If NET is installed on a system, releasing » program is as simple as coping its EXE file to the target system 7.ASP.NET - center of web application development ae ee 5 ica) ASP.NET. ASP.NET makes it Px NE programming design applications, 10 gel good organization a Za encourage encapsulation and reuse. ASP. ‘center of web application development i When a web server receives ane S it performs a necessary proceseit ae: the page sponse back (0 the response before send browser, ASP.NET nology at the center of that ‘processing witich generates content and client ide code a5 well as server-side code ASP.NET brings the full power of object oriented iques to web development. Everything in » NET is extensible and reusable through iymorphistn. d polymorph inheritance: ve WADHWA's Selected Questions and Answers 45 Q2.(b) Why CLR is called as heart and soul of NET framework? MDUBCA 2018 OR Explain why Common Language Runtime is heart and soul of NET architecture. MDU BCA RE 2017 oe We of language runtime? el a a services provided by the Siena the benefits of CLR. What are the ane 7 Role / Functions of Common Language Runtime (CLR) in .NET framework? Also write the benefits of CLR. Ans. Common Language Runtime(CLR) The NET Fraimework provides a rantiome environment called the Common Language Runtime or CLR. (is the soul and teart of NET framework. Te manages the execution of code and proviles services hat make the execution of code easier. “Runtime” means that code is running, which ix another ‘way of saying it is being execuced. “Common Language” means that this runtime manages the execation of code ‘whiten in several Tanguages thot share the services provided, The CLR or the .NET rontine serves a5 the execution engine of .NET framework. teat aso Be termed as the foundation of the All NET programs execute under the contGarbage collection is the mafor Toe prevents memory leaks during execution of programs “The garbage collecior of CLR svromatically dete the best time to free the memory, which is reserved by an. object for execution, |. Exception Manager sxceptions thrown by atch block provided by ty i used in NET f Impose restrictions and security during execution ofINTRODUCTION TO_NET pu 48 programs. CLR allows an executing code to pertormn on! tose tasks for Which it has permission. Also the CLR checks for user's permissions by using authentication and configuration files of NET applications 5. Thread Support ‘Threads are managed under the Common Language Roniime. Threading means parallel code execution Threads are basically for multi-tasking within ight weight processes responsible single applicasion, 6, Code Verification TELR enforces type safety and prevents a source code from performing illegal operations, such as accessing Jnyalid memory locations _ Tool Support The CIR works hand-in-hand with tools like Vi " Stiio, compilers, debuggers and profers fo make the " developer's job much simpler. |. Code Manager When one compile 2 “generated that can actually gctually generates Microsoft idiate Language (WISI. or just JL). All NET code fe, 1L code is also ealled Managed Code, because simon Language Runtime manages i R manages code ation, the code is not te onthe machine. One tion of NET code the MSIL code to mach TCLR also determines depending id compiles WADHWA's Selected Questions and Answers _49 fon platform what is optimized way of running the MSIL ode. 10, Multi-language Support CLR provides multi-language support by managing the compilers that are used (o convert souree to intermediate language (IL) and from IL. to native code, and it enforces. program safety and secunty. Benefits of CLR “The CLR provides the following benefits: + Provides tite ability 10 uce components developed in tier languages. ‘+ Improvement in performance. + Provides object-oriented features such as. inheritance, interfaces and overloading for ‘oriented programmin; i + Automatic memory management by collection. + Provides tread execution management. + Security enforcement. © Supports. wre of delegate ‘pointers for increased type s + Provides support fe“new vision, philosophy and endeavour “towards funure of Internet computing. Ic is a vision of “how the information technology will evolve. Ia vision “to empower people through great software that operates ‘on anytime, any place and on any device, “This isto exploit the power of the Internet, (0 an extent that people ean use any computing device to do whatever they want to do anstime, anywhere Itallows to create traditional Window based applications, server components, and applications that can run on any Available with it, ‘The developer uses the programming language in wins he/she feels comfortable. It is the headache of the framework to make the code compatible on every machine and produce the seme results. Thus, NET provides a common development platforms to the global developers and brings them sitogether. NET amework inciaes the follgh objectives: 3 conflicts. ‘INTRODUCTION TO .NET 52 WADHWA’s Selected Questions and Answers 53, © It provides an cnvironment that can successfully execute the code cteated by an unknown user It provides an envionment that can be used to execute both window bated and web-based applications '* It provides facilities 10 enable all applications to communicate with each other Thus, Microsoft .NET is a new plaiform designed to provide all the tools and technology to build Web ‘applications. It allows software developers to easily migrate from existing technologies, to build seamless, language independent, Internet platform neutral, reusable, robust and consistent software components that can be shared among developers to make people oriented software a reality. Building blocks of NET platform fing blocks of NET platform are: Buil 1. CLR (Common Language Runtime) 2, CTS (Common Type System) 3. CLS (Common Language Specification) CLR (Common Language Ru itime) vem poves wie eet Bie cs : ‘Runtime or CLR. It is the called the Common Languase i Ie manages the soul and heart of NET framewor . fe and provider services thot male the execution of codi execution of code easier “Runtime” means that code is running, which is another way of saying itis being executed, ‘Common Language” means that this runtime manages the execution of code written in several languages that share the services provided. The CLR or the NET ime serves as the execution engine of NET nework. It can also be termed as the foundation of the NET framework. All NET programs execute under the ‘control of the CLR. In addition 1 executing code, CLR provides services such as memory management, thread management, security management, code verification, compilation, and other system services. It enforces rules that in wm provide a robust and secure execution environment for .NET applications, ‘The .NET compilation oceurs in two steps: (a) Compilation of source code to MSIL. (©) Compilation of MSIL by CLR (a) Compilation of source code to MSIL, NET framework is shipped with compiler: of all programming languages o develop programs, There ae separate compilers for the Visual Basic, C# and Visual programming languages in NET framework. Each NET compiler produces an intermediate cade ater compli the source code. The intermediate code is eommnion for all languages and is understandable only to NET Mit. environment. This intermediate code is knows (Microsoft Intermediate Language). a a‘the codes of NET mpli ‘converted into MSIL by their compilers i.e. all managed code compilers for Microsoft NET generate MSIL. ‘MSIL is machine-independent and can be efficiently ‘compiled into native code. MSIL has a wide variety of instructions: ANET achieves the language exchange ability by sharing 2 ‘common data type system with all the languages. This shared data type is known as Common Type System’ (CTS). ‘The CTS defines the rules by which all types are declared, defined and managed, regardless of source Janguage. This means that type int in C++ language isthe same as the type int in C# language as both of these types are derived from the System Object class. In other words, two CTS-compliant tanguages do. nat require type conversion when calling the code writen iaINTRODUCTION TO NET a” fone language trom within the code writen in another languag CTS provides a base set of data types for all the languages supported by NET framework. This means that the size of inieger and long variables is the eame across all NET-compliant programming languages However, each language uses aliases for the base det Iypes provided by CTS. For example, CTS uses the datn type System.Int32 to represent a 4 byte integer value however, Visual Basic uses the alias Integer for the same, whereas CH uses the alias Int, This is done forthe sake of clivy and simplicity Common Type System (CTS) is designed to be rich and flexible enotigh to support a wide variety of sor-ce Tanguages. It failstes cross-language intcgraion, «ype safety, and high pesformance code execution The Microsoft NET framework supports cwo categories of types: Value types and Reference types. The Value Types are passed by values and store inthe Sack. The Reference Types are passed by references and Store inthe heap CLS (Common Language Specification) A goal of NETis to support language integration in sich 4 way that programms can be written in any langage, yet ‘Gan interoperate with one another, taking. the il vantage of inheritance. polymorphism, exceptions and ther ferures. However, languages are not made equ aube one language may suppor feature tat is otally WADHWA’s Selected Questions and Answers 57 different from another language. For example, Cy Supports decimal type and C++ does not support decimal ‘ype, managed C+ is case-sensitive, but VB.NET is not tn order to bring eterone othe same she of ee Microsoft tas publsied the” Connon” Caran Section (C13) CLS specifies series of basic rts that ore reir or lngnage integration. The CLS sa bse of Cs and therefore the langagessapporng the CLS cae seen thr ls lorie Thus CLS provides a taf ls which ae een to be followed. whe developing a NET comp trogen language. Err vend sf fl thee ils an design tie aging to cow) NET fete oFfant programming lang. that objects of the programs that are waitten in Hifferent progrimming languages can cos trmunicat with) ‘each other fo share data ETS prevents data loss when a type in one language transfers data to is equivalent «ype in other langusge, Fr example, CTS ensures that data is not Tost whi) ‘transferring an integer V integer variable of CF code. “The Common Type System (CTS) defines a set of ‘and rules that are common (0 all languages targeted atINTRODUCTION TO NET a0 LR. It supports both value and reference types, Value Iypes are created in the stack and include all primitive types, structs, and eriums, In contrast, reference type created in the managed heap and include objects, array collections ete. 3. Multi-language Support NET provides multi-language support by managing the compilers that are used to convert source to intermediate Janguage (L) and from IL to native code, and it enforces program safety and security ‘The basis for multiple Language support is the Common “Type System and metadeta. The basic data types used by the CLR are common to all languages. There are therefore no conversion issues with the basic integer, ‘ating point and string cypes All languages deal with all data types in the same way. here is also a mechanism for defining and managing CLR works hand-in-hand with tools like Visual fo, compilers. debuggers and profilers to make the throogh user and code ity of WADHWA's Selected Questions and Answers 64 Hp Simplified deployment ‘major feauure of NET. The NET framework also provides support for role-based security using Windows NT accounts and groups: Automatic Resource Management ‘The NET CLR provides efficient and automatic resource ‘management such as memory, sereen space, network connections. database efe. CLR invokes various builtin functions of NET framework to allocate and dealloeate the memory of INET objects Therefore, programmers need not write the code to explicitly allocate and de- allocate memory to programs, Easy and rich debugging support ‘The NET IDE (tegrated Development Environmen) provides easy and rich debugging support Once an ‘exception occurs a fn tie; the proaram stops and the IDE marks the line which contains the eror along with the details of that ertoc and possible solutions. The runtime also provides buili-in stack-valking facilities, ‘making it much easier to locate bugs. With NET installing orCLR-compliant language is complicd, it generates seippeniont a imarpeaiat cose Tht WES p Sater applications. In other words, ppl Sega ‘used to isolate the processes of different appli 11. Cross-Language Integration ins how thanaged 15. Ready and Developer Friendly \dy-made_ components ‘any code. One can just The Microsoft NET provides + for which one need not to we rag and drop the component from the component lis. f Moreover, the Microsoft .NET platform has been Built methods and pro : soto Iibnifis ftom VB.NET. The tick to from the ground up with numerous goals in mind this is writing programs that we CLR- in fic (0 ipeloding security, scalability, relicbiliy, Mexbili i = iorepecsbilty
ENeb: Ices cas wok with ner Protocols soch as IP and Sockets | ess_ (System. Dat t with extemal data, 1ypicaly a database. This Incldes. classes to used by the ASP.NET data contol. ‘+ Reflection (System-Reflection) Includes eases tht Allow @ programm to look at itself to tdemiy its own characteristics, such a8 specialty datatypes and the organization ofthe code. Globatization (System.Gobalization Heludes classes that hold cultur-specfie stings such 8 syntax of dates and Sure. . sures (System.Collections): Ineiudes re resem ein aso ani .NET ncloding lists, dictionaries an Rath ables, Web) Includes Web Apion Mod eas: the server “This eas incl ‘on various types ofICTION jyTRODUCTION TO NET. WADHWA's Selected Questions and An: 97 (q7(6) Explain the concept of assembly in NET. Fcabtces chan Aten )y MDU BCA 2016, RE 2015 Te : 1 features of an assembly ae the followin aa 7 bly ae the Following: a 1. Astombiies are seitdeseribing. All the details about What are assemblies? Explain thelr features setenad cetare tit needa NE and basie structure. Also explain the types of J os es PA ie Katliet ded inside assembly ‘Ans, Assembly | 3. Assembli side-by-side series € b-side An assembly is the logical unit that comains compiled ‘code targeted at the NET Framework, Assemblies are the primary building blocks of NET Framework applications. In .NET, every application ts compiled into an assembly. which refers to 2 Porabl Executable (PE) file, The PE file can be either a dy! link brary (.DLL file) or an executable ‘contains the MSIL code of the com, Ma, addition 9 the MSIL, NET assembpes ® iadata nites, that describes all the types (¢ interfaces, and enumerations) that the assembly, with information al ‘= methods, properties. ‘events and fields. The metadsta of NI information about the files that belong ‘and the exact inf co) i Jeblies can be private or shared. sie Structure of an Assembly ‘The basic structure of an assembly is shown below: IFT assemblies also provides to the assembly, formation about “Assemblies are made up of four sections: version information, ‘Assembly Metadata 1 assemblies that are used. ee i weit ‘ype Metadat ‘Asseinblies a self-describing » installation tosing of ee oz oore fies Ose ase C28 6 ee bP iaies ta, or it eth 3 nae Language single DLL of EXE that ineludes metods cer cor dintrent fee ~ for mame, rsaurce SCSINTRODUCTION TO NET 98. 1. Assembly Metadata ‘Assembly metadata describes the complete assembly. “The assembly metadata is also known as the assembly manifest. Some of the assembly metadata’s contents are + The name of te assembly. + The version number. + The culture used by the assembly. + Public key and digital signature, These provide a uniquely identifiable ID of who created the assembly. + A list of ail files that make up the assembly. + A lise ofall referenced assemblies. + Reference information for all exported classes, methods, properties, and so on, found in the assembly. 2. Type Metadata Type metadata describes the types (classes, structures, imerfaces and enumerations) within the assembly. It also ‘cootains all the publicly exposed types and resources. “Resources are files such as BMP ot JPG files or any other ‘Ble needed by application. 3. Microsoft Intermediate Language (MSIL) code MSIL i the key © NET's cepubility wo be language seenl All ox, so mater what the programming Language. 1 compiled into the same MSIL Because ail lengoages alimercty ¥ 3 WADHWA's possible for encap: Excepsion handling, debuggina Pearl. MSIL is also one of the Keys to NET fo be platform independent. With MSIL prt once, un anywhere” ability 4. Resources NET resources (such as string tables. cursors) can be stored in two places: files or directly within an asse ‘ither foeation is extremely easy NET Framework base class library provid staaightforward classes for acces ‘System,Resources namespace These are '» ResourceManager: Used to access re within an assembly «© ResourceWriter: Used to write resource: external resources file + ResourceReatler: Used (0 read resource extemal .resouress file. In addition to these classes, the NET Frame provides the utility resgen.exe, which creates @ reso file from a tex file containing key/value pairs ‘Types of Assemblies ‘There are two types of assemblies: 1. Private assemblies 2. Shared assemblies 3. Satelite assembliesES, 1. Private assemblies A private assembly is an assembly that is available to porticular application where they are kept ie. a private assembly is used by the clionts of the same application directory structure as the assembly With simple, .NET applications, using only private assemblies is the best way to work. No special ‘management, registration, versioning, and so on is needed with private assemblies ‘The only application that could have version problems with private assemblies is your own application. Other applications are not influenced because they have their own topics of the assemblies. The private components ‘you use within your application are installed at the some time as the application itself. Private assemblies are located in the same directory as the application or subdirsctories thereof. This way, you should not have any versioning problems , with the pplication. No other application will even overwrite {your private assemblies. Of course, itis still a good idea to use version numbers for private assemblies too. This itis not a requirement of NET. helps a Jot bu 2. Shared assemblies A shared assembly is a public assembly that is shared by multiple applications. With shared assemblies, several applications can use the ‘and have @ dependeney on it. Shared same assembly isk and memory space assemblies reduce the need for id Answers 101 WADHWA's Selected Questions With shared assemblies, many rules must be fulfilled ~ 4 shared assembly must have a version number and a unique name, and usually it is installed in the Global Assembly Cache (GAC). The GAC enables you to share different versions of the same assembly on a system, Satellite assemblies An assembly with culture information is automatically assumed to be a satellite assembly. ‘These assemblies are used in deploying Global application for different languages, Sutellite assemblies ‘are used to build multi-linguistic applications. These language-specifie assemblies work in side-by-side execution because the application has a separate product ID for each language and installs satellite assemblies in 2 Ianguage-specific subdirectory for each tanguage.102 INTRODUCTION TO..NET ee $e Q8.(a) Explain the concept of manifest in NET. ian MDU BCA RE 2016, 201 015 oR What is manifest in NET? What information it provides? ‘anifest in .NET NET applications are organized and packaged into ‘assemblies. All code executed by the NET runtime must bbe contained in an assembly. The assembly contains the code, resourses and a manifest (metadata about the assembly) needed to run the application. Assemblies can be organized imo a single file, where all this information is incorporated into a single DI files whete the information 1s incorporated int DLL files, graphics files and a manifest files. Mavifest is one of the most assembly. In fack, every as manifest. The parpose of, «| A description of the classes and other data types the assembly exposes to clients + Any other assemblies i needs to reference and + Security detaits needed to run the assembly, aces Ot tan econ ‘A manifest contains information ‘whole, Manifests contain Naming and version information that can be ss, the runtime environment {0 ensure that they toading the proper version of & file when te, wants itn ree i ic tanrs, is permitted to access when itis run the types found in the assembly. Types ‘application, fundamental building blocks of U ‘also because, without them, one can not wie ic functionality installed in the assemblyWADHWA’s Selected Questions and Answers 105 rpoDucTIONTO NET 108 aim Describe metadata in NET, MDU BCA RE 2016 or ea about metadata in NET Givea brief Ans, Metadata ‘Metadata is information about the assemblies, modules ‘and types that constitute NET programs fn NET, meta -chanism that the NET runtime, compilers and tools all can use. Microsoft NET ties metadata to describe all types that are used and ‘exposed by a particular NET assembly. describes an assembly in detail In this sense, metaca including descriptions of its identity (2 combination of an ‘assembly name, version, culture ond public key), the types that it references. the type that it exports and the eeurty requirements for execution. Mach richer than + type library, metadata includes descriptions of | A# Daembly and modales, classes. ilerfaces, methods propenies fields, events. plobal mei and 60 forth Metadita provides enough information for any runtime, tool or program co find out literally everything (at 1 ‘needed for comiponent integration Users of metadata in NET Fotiowiog exe. dre scars cmt mate, ICIP Se of metadata in NET: CLR The CLR wes metadite for verification. security enforcement, memory Iayeu! and execution. The CLR Telies heavily on metadata to. support these runtime features. . Class loader ‘A component of the CLR, the clas Joader uses metadata (o find and load .NET classes. This is because metadata records detailed information for 2 specific class and where the class is located, whether it is in the same susembly, within or outside of a specific namespace, or in ‘dependent assembly somewhere on the neswork. Justein-time (JIT) compilers ATT compilers wse metadata 10 compile WL code. NET IT compiles TL. into native code priot ta execution ani ic oes this using metadata. 1. Tools “Tools ose metadata to sipport integration, Tools sachs deboggers, profilers and object browsers can use metadata to provide richer development sOppor. Ls406 waunw » ae INTRODUCTION TO .NET a rea eR Jes are expecially important in Cy = Data 1p! Q9.() What are various data types supported by CH? se eranaly oped tenivese. This Mlustrate. ‘MDU BCA RE 2018 tpevaions are type check YU cmp OR Sere ig, Mlegal operations vit What are data types? Explain different Ee eta Grr-checine nin categories of value types and reference \yPes compile. Thus sans O76 3 eure DU BCA 2016 srrars and enhanc oR fae What are data types? Explain different data Ch Dae Qy types supported by C# language. his a eapp@N GD ad sich TangNsge. Fen "Ee BCA RE 2015 cn Eeoaia sts type. 7 Gp dora. types available in fe select the (pe approprine OR ‘What do you mean by data types? What is the 1b importance of data types in a language and also ie KOS serement of the application. Data type: in ( SY especially in C#? What data types are ‘categorived mainly into (wo (YPes supported by Ci. Illustrate the use of each 1. Value types: through suitable example. @ ‘Ans. Data Types <6) 5, ea feo ee ae eee eS Pyare peered The Valve types directly contain data, Valuc 1 fixed length and are stored on the stack of rx Acdata type determines the _) rations that can be performed on the dat ° When @ value of a variable is assigned t Variable, the Value is actually copied. This mn aa two identical copies of the value ure availab: ‘efficient storage of data for an memory Value types are of three types + enables an efficient processing of data. (a) Simple types (Predefined types) “+ Uhelps in the data protection and management, + We enables 10 represent the inherent relationship of dara in the real world. (b) Enumeration types (User-defined types) (©) Structure types (User-defined types)Fae S { { | WADHWA's Selected Questions and Answers _109 wo gyrQUGTION TO NET 108 { | Type | size | Rance ‘ Value Types ee =a re coe fe [22800327 Simple a “*Structure ‘Types numeration ‘Types short | 16 = 32768 to 32767 Types y Via fae | -aeraszess vo aterassoe7 sbyte ‘ Jong | 64 - 92233720368S4775808 10 sho ' “i Be ; 4 Predefinec } bye oe i «The keywords byte, ushort, wint ond ulong are of ue Taigucd ineger dasa ex These wsigned ites the ae mya only. postive mbes. THYS, BS oat { PrEking the integers *ansigned”, one can increase the goa ane one vaucs. The size and ange of a) pes shown below: scemnal i Type [sie | Renae S| vis) i (@) Simple types i pe [8 | ovwass These ac the types that ae bul nto te Tansee ; Bao legac +The keywords syte short, ntand long ce ofsioned | eae ital one inugger dana ppes. Tes oped integer (Pes At haere ds pomaive and eeatve murners, THe Se ong | 61 | ovo r8sdortaarsro9ss1618 and range of these types is shown Below: «The keywords float snd double are of floaving pov data pes. A fating pont type can Hold a fretionat pat of a nannber like 654.25. To specify rims 10INTRODUCTION TO_NET 110 Re be af Moot type, one must append the character F or f to the valuc such as 684.25F, If one omits F, the valle Will be treated as double type. The size, precision and ‘ange of these types is shown below Type [Size [Precision] Runge kin wits) I Moat | 32 | 7digits | 1.5<10~* to34x10" double 15.16 coe pire UAE | sox10™ to.7 «10 The keyword beal is of Booleas data type. It is used to declare vatiables to store the Boolean vals, 11 and false, One can assign & Boolean valuc 19 « boo! rariable, for example: bool MyVar = «rue: (One can atso assign an expression that evaluates (0 boot 10a boo! variable, for example: boo! Value = {a>20 && b< 40); “There is no conversion between the bool type and ‘ther types, + The keyword char is of Character data ope. Character data type stores single charaeter_ in ‘memory. C# char represents Unicode character set. “This Unicode uses 16 bits per character. With 16 bits per character 65,536 different characters can be ‘represented easily. WAH) SS + The keyword d deckmal Keyword denote Compared te floating point typ. fas @ erenier precision and. smolle takes wlable for final ds} Exieulotions. The decimal numbers can 10x10 to 7.9%10™ with 28 10 29 To specify & number to be append the character M or m to the v 345625M, If one omits M. the as double (b) Enumeration types eis nis. Enumerations are the user defined intege are declaced using the enum key the readability of code, | enum Directions {North, South, East, West By default integer values 0, 1, 2, 3 are assigned symbols North, South, East and West respe (©) Structure types Structure data types are ereated usin, Keyword. A struct is usee defined data type thst « Of @ eollection of similar or dissimilar data ype *|urmo0UCTIONTONET Sa cprrne on ese dae ee aru (pes are also ioed on a Mee ttn ant cooveriers mens Meg telecon datatypes. Morcover ine ree Pampa ond ected ecleny (ii) String type String type is sed for cresting and manipulating strings in C#, One can perform various operations on strings, | WADHWA’s Selected Questions and Answers 113 | concatenating on these 2, Reference Types such as copying. comparing string objects ference types are sored on th imemnary. When PERE A iscsi setersce vases (b) User defined, ale 10 be | fi nly the reference is copied and the actual valve remains Vie EDR oe ter wo tse ps whieh the same in the memory location, The reference types are conga Nog predefined types. These are further die if I calegvis | ph igi b= at Ne KC ‘The keyword class is used to declare a class. A class 2. Userdefined types holds both the data and methods oF functions, Functions eo oS orion ae ee oe OS) . {SS See ranma veri ye OS ie rie Sea or oriented language, 0 the base of all the CA programs is Mie tok ceteris aoe cae pager {group the logically related data members and methods that work on them. (a) Predefined type: 0 Intertuces “These ate the types that sheboilt ito the language, These are further clivided into Iwo types: ‘The keyword interface is used to declare an interface ‘that contains the signatures of methods, delegates or @ Object type ‘events Le. interfaces are a collection of members, such as Objec type is the wltimate hase type of all the other methods, delegates, events and properies which are implemented by classes. Interfaces can not be instantiated but one con use them to offer a set of functionalities that is common to several different clases. The concept of asics ae aleuicen aa: predefined mid user defined data typos im C4. One can ‘ise the object type to convert a value type on a stack int _an object type to be placed on the heap. veAwi cline “dain!mei a. waonwa's selacted Questlon® ate between Value LYPE ANd Fer INTRODUCTION TO NET ce 9.) pint inheritance because in Ci, a class does not SYPPORL :muliple inheritance (ii) Delegates The keywon! delegate is used to declare delegate reference type. Delegates are the objects thot point towards a method which matches its signature ¢ that delegate. It is type-safe, secure and can be instantiated BY associating it either with a named or amoaymous metho (iy) Arrays The Keyword array is used fo declare array reference type. An array is an ordered arrangement of dots cements It a data structure that coatains 2 number of ‘Sariables of the same type at contiguous locations of the ‘Ans. Differences betwe MDU NCA 39 data (PS on Dirterentiate between Vale aid Rete Hat types wih examples. What Jo you by NAN dato type? MDU RCA Ri n Value and Reference types 1 Akey difference between 3 value 1yP type is the memory loc ‘With a value type variable, it cont the variable, such as 3.1816 oF 3 By contrast, the memory location ass ains an address reference (ype variable con pointes) that indicates where the actus! ‘memory. 2, Local variables of value types are stored always sack A stack is 2 data structure that stores items firsvin-first-out (FIFO) fashion. It is an are2 of = supported by the processor and its size is deter: the compile time. By contrast, variables of reference types allocated on heap memory. A heap consists of available to the program at runtime. The allot one éynamically during the execution time 3. While assigning or copying in a value type, 2 *= ‘value is copied by creating = separate copy variable in memory. Therefore. an assigament o7-=**NTR: ICTION TO .NET 146 results in two separate, but identical, copies of the value inmemory Example: int x= 100; variable xis holding integer value 100 ‘variable value is assigned to y variable Now both x and y variables will have values each 100, By contrast, assignment statements between two reference variables result in to references toa single 6 value at one location as shown through the ae variable KI acts as a pointer tos string k2 = kl; kL TET area SOE 2 ‘When value types are passed to methods (or procedures) as arguments, the exact copy ofthe value is passed. Example: ted Questions and Answers 117 WADHWA's Sel using System: namespace Chapier01 i publi class ValueTypes i ppublie void swapCint x, int y) % i int temp = 0; 2 2 oun “= 400, b = 700; ValueTypes vi = new ValueTypest Console: WateLine("Before swapping 3 > veswapta, B), Console, WriteLine(“After swapping a = (0), r ) ) Output: Tefore swapping a ‘After swapping a= 400, b= 700 By contrast, when reference types are passed t0 ‘methods (or procedures) as parameter, then only a reference to the object i8 copied and not the actual contents, Example: ‘Mlustrate of reference types passing to methods.INTRODUCTION TO .NET ee using System; ‘namespace Chapter01 ( public class ReferenceTypes ( public void swap(ref int x, ref int y) ( int temp = 0; temp = x; y y= temp, ) ) public static void Main( ) { int a = 400. b = 700; ValucTypes vt = new ValueTypes( ): Console WriteL ine(*Before swapping a= (0). 1", a,b); ‘veswapleef a, ef b): Console: WriteLine(“Afier swapping 2 = (0), b=(1)"a,b); ) 1 Output: Before swapping a= 400, b= 700 After swapping a=700, b= 400 5. The value types when not initialized explicitly, gets initialized with O in case of numbers, false in case of ‘bool type, and by value \0" in case of char. | WADHWa’s Selected Questions and Answer |n an object Is n0% initializes p By contrast, when : itrefers to what is known as cull {6 The value types are disposed once they leave ‘The disposal of reference types is done aviomac aa method known as garbage collector NaN data type NaN stands for Not a Number. It is the res when he tries to do math with a sti calculation fails or cannot be done. For ex impossible to calculate the square 1001 of a number, Trying to do so will result in NaNjyrmoDUGTION TO NET 120 plicit conversion is different nie Elaborate how from explicit conversion. Perform anyone type ofexplicit conversion. MDU BCA RE 2017 Ans, Object of one type can be converted into objects of another type. This is called casting. Casting can be either ‘implicit or explicit ypens automatically ‘An implicit conversion compiler takes care of it, i.e., implicit conversion cecurs ‘automatically, without special method call or cast operator. For example, converting an int to a long con occur as a normal assignment operator as follows int mylne = 6; Jong myLong = mylnt; \iPovcur. The When itis put into ifs the same thing - @ and the itis 32-bit value, The int a with 0 problem. Second, no semantics ofan int value a long variable, It ‘whole mumber. On the other hand, explicit conversions happen when ‘You specifically cast a value to a different type by writing the new type in parentheses. In other words, 20 explicit conversion is required when the same principles 49 not lead to a positive result. To be more specific larger types moving to smaller types or anything that can Possibly generate an error require an explicit conversion. vA This conversion occurs without any problem pesay aN ‘wo simple principles. First, the long is oO@4@ea, Witong WADHWA's Selected Questions and Answers 121 For instance, going in the opposite direction of the previous example, long to int would require an ex; conversion because it is possible for a Jong value to be large than what can be represented by an int type, This forces the programmer to make a deliberate decision that could cause corruption of data, Here is an example of ine ee Ee NO eases the resale ofan arthnetie te eee eeummopucrion yo Ne WADHWA’s Selected Questions ane Answers: Bi veies 7 8.201 ‘The Ce is (Next Gene Q9.(d) Explain the characteristics of C4. ‘emerged as a language for ation Windows Services) a7! ‘Ans. The characteristics of C4 are the following: 1. Simple ict orragement atomic 204 0 Moder mem Tg of he pcaramnss Th ste i Sy smanngeenca te responsibilty of C¥ pt One! | a ester roi fete of CH a pee | apps erous hogunge excepuon handling. § ee sions Bees sera & sed 0 CF for if es sch “5 Ore atone: Anoiber todern feaiue of CH ta de ‘supports a robust security model. reat Object-oriented e oe (Ge isan object oriented programming lanzvses ter cr ing ematy of exsng coe 20 i object orient redundancy. It supports major Jog features such a8 data encapeltc, Jnberitance and polymorphism Consistent ‘Ch supports wnified eype system which cfiminses te problem of varying ranges of intcest types. AIL De freated as objects and developers can extend (ef system simply and easily. Versionable ‘Versioning is the process of evolving an application eoraatble manger, CP supports beth sows and ted compatibility in applications The source compatibl® ‘means tha new version ofan application con work nt the previous ‘version of the application on ‘recompiling previous application. Binary compabiliry means 4jwrgo0ucTION TO.NET 124 cris version of an application can work withthe new Tenion of the application without recompiling. the revs version. Thus, CH supports versioning. that Enables the existing. applications to run on different 6 Flexible In CH, code can be writen either in safe mode or in unsafe mode. The defoult for CH cod is safe mode which does. mot suppor pointers, But one can declare certain classes of certain methods of elasses to be unsafe which enables the use of pointers. This shows the flexibility of CH language. 1 Interoperable CW provides support for cross language interoperability The code produced by C# can work easily with the code produced by other languages. This is made possible through the CLS, which defines a set of rules that every language in the NET framework has to follow, The Ci programs can use existing COM objects, inespective of the language they are written in. 8. Compatible CH enforces the NET common language specification and therefore allows ineroperation with other .NET ‘anguage, ‘Type Safe ‘The Common Type System provides type safety. which ‘in ten improves code stability. CM provides the following, ‘ype safety measures: ind Answers 125 WADHWA's Selected Questio! = One-can not use uninitialized variables. © tt enforces overflow checking ‘operations. Me checks the range of an array and warns when the access goes out of bound. + Dynamically allocated objects and arrays are initialized to zero. © I supports automatic garbage collection. arithmetic 10.Supports Garbage Collection “= Garbage collection isthe proces of recovering eomputer memory that is no Tonger required by programs. 1 the feature of NET thit C# supports. Thus, garbsge collection automatially reclsims memory occupied by unas objects 1. Exception Handling a ‘The NET standardizes the exception handling across languages. Exception handling provides a structured and ‘extensible apptoach to error deteétion and recovery. The Cw tanguage’s n handling features provide a way 10 deal with ¢ ‘of exceptional situations that arise while a pr running. 12.Security * CH security is designed to operate as pan of ‘runtime and provides several builtif you add these 10 rounded to 1234567, be Q104a) What do you mean by integer overftow Mating point round off error? MBU BCA 2017 Tom ean hold. Tho error introduced by rounding vf Ans. Integer Overflow seven digits can become large compar mpate. especialy wit e ‘An Integer Ovesfiow is the condition that occurs when cote Oy the result @f an arithmene operaion, such a meray the binary BeG@ARRYPL Fe a ay ‘multiplication or addition, exceeds the maximum sce inary ftion, PAA! fraction, Ths news 2F the integer pe used to sore pcepaieeee) accuracies can occu weet pie O- double number “Type int epresens positive and pegative whole nurbers é ale of 140.6 is te fi Sich a5 -2123 of 4567. In CA, 4 bytes of mexmary are Siinlor ofthat faction 1 00 power of tna used 1 slo 4 valve of type int. Thus, che posible ctor, cannot be represented exactly by sn values of type int range from 2147483618. Wo, Gere eee tie 2 sly epsenn the’ clotes friction with = power of two iw 2147483647, While this might seem like 9 fab large range of values, itis important 1 realize th Jarge as it is, itis still a finite set of values. there are mathematically an infinite 7 and negative whole numbers, type it denominator that will fit into the 16 bits ofa Neat : ‘Since the double can hold a more accurate value tan te float Gan store, the C# compiler will actually evhse this expression fo: double number = 140,600006103516 pen fechee 10 s00006103516 he clone ya fo 40 ln Tis acon sehy ley he a eee 140.6 when represented as a double. type int. The big result f rope = |The errar produced due to the rounding proces is called round of error. ‘A lot, with sven decimal digits of precision, can bold ‘the value 1,234,567 and the value 0.1234567. HoweverjwrnooUCTION TO_NET 128 qiag@)Define Mterals. Explain different types. of literals with appropriate examples along with their uses. MDU BCA 2018, OR Define constant or literal. Explain different types of constants available in Ci, Ans. Literal/Constant Constant is a quantity that does not change. Constants ins Of refer to fixed values that do not change during the ‘execution of a program. In Ct, itean be declared as follows: accets-modifiers const data-type constant-name = value For example: public const int A = 10; ‘Types of Constants in Ct 3 The following types of constants are supported by CA: 1. Boolean 2 Numeric 3. Character 4 String 5. Nall WADHWA's Selected Questions and Answers _129 1. Boolean Constants Boolean type represents a true or false type value The value true and false are the only two possible Boolean constant values. [Numene valves such as 0 and | can not be treated as false id tre respectively. Boolean type does not accep! any, umerie value as is value. 2. Numeric Constant Numeric constant may be an antegral ype 0 eat type (a) Integral Constant ‘An integral constant refers to sequence of digits without decimal point. An inegral constant is one of the following types soy, byte. short, usher int wit, ong, ulong and eae Comma anki blank space cannot be included within integral constants, ‘an integral constant may be preceded by a pls sign desired, or a minus sign, IF a sign does not appear, the integral value will be astumed f0 be postive, Integral {ales should nt go beyond the makin and minimum ales that can be represented bythe specified wumber of bits used by the system for each integral data (PE representation. An integral constant may cnd with 1.or L fepresenting long integer, w or U representing unsigned inte, . er ae Integral constant may be represented sing decimal digits ‘or hexadecimal digits. AINTRODUCTION To NET 430) Decimal integral constant A decimal integral constant is formed using the digits 0 through 9. A decimal value represents a number system Using Base 10, | The following are valid decimal integral constant 35 — 434 435926U On the other hand, the following are not valid. decimal integral constant $4.0 contains a decimal point 34.45 contains a comma 56 56 blank spaces are not allowed within an integer (i) Hexadecimal integral constant A exadecimal integral constant is formed fr sc hexadecimal amber system 0 toosh 3 (Giter epee o lover), leat The characters A tirough F 10 through 15. ° ‘The following are valid 1aHhtegral constant» 0x6 0x60 cD On the other han? the following are not valid hexadecimal integral constant 55 Not leading with Ox or OX. OXabh Only A through F (or a through f) and 0 through 9 are allowed. OX:GaF Decimal point is not allowed. _— WADHWA’s Selected Questions and Answers (b) Real (Floating Point) Constant Fem) ASS he air ede expand Wag uivaent 1 3.510" onstant are decimal notation or an integer. The exponent is always an integer number with en optional plus or negative sign A real constant may start with a decimal point (,) but One or more digits must follow can not end with i the decimal point, © The mantissa part and the exponent part should be separated by leer + Special characters except e, E, 4, ~ and . are nol alfowed. + Floating constant should not exceed the specified limits ofthe values ofthe system used.ra JUCTIONTO_NET 132 {© Decimal Constant fee rectal dat yp called decimal, 1: denones 128-its data type. Compared to floating point types, decimal ype basa preater precision and a smaller range, tien makes it suitable for financial and monetary calculations. The decimal numbers can range from 10x10 to 79x10 with 28 t0 29 digits precision. It provides exact ccsion compared (© float oF double type avoiding roundoff erors that may occur in curreney calculations To specify a niimber to be of decimal type, one must append the character M.or m to the value such as 345625M. If one omits M. the value will be treated as doable, Decimal constant may also use exponent notation 48 1SE22M, 154.24E11M ote. . Character Constant A character writen within single quotes is called a character constant. The character may be letter, number or special character Rules for character constant: + A character from the character set of CH can be enclosed in single quotes. + An escape sequence can be enclosed in single quotes. + More than one character is mot allowed in @ ‘character constant. An escape sequence consists of ‘more than one character to WADHWA's Selected Questions and Answers 193 ‘character. Hence, it is treated as a single character only. + Atleast one character is written in single quotes, Examples of character constant are: saree yy 4. String Constant Ci supports two types of string constants (2) Regular string constams (©) Verbatim sing constants (a) Regular string constants A regular string consiant is sequence &f zero or more characters enclosed within double quotes such a8 “India «Ram Singh”, “L42" orth empty string" "The quotes se noc the par of the tring ca () Verbatim string constants A verbatim string constant is string constant prefixed with the @ charactez. Any escape sequence in such a string denotes itself as such and not process. The only exception t tis is two eonsecutive double quotes (*). IF ** occurs in between tbe verbatim sing constant it displays single character“. The character” "ys Known as quote espe sequence nthe coment of verb sg constant. ‘Valid verbatim string constants Display @ "Welcome to C#INTRODUCTION To NET 134 @ “Welcome to\ace” Welcome to \a C# @ "Welcome to "* Ce" Invalid Verbatim String constants “Welcome to i C8” S, Null Constant ‘The null Keyword is constant used to indicate that « ‘Variable does not hold a known value. Jt is used only with a reference type and not with a value type. Welcome to" C# isa regularstring constant. oe : » 3 ae ¥e } A lie | he WADHWA’s Selected Questions and Answers_ 1046) Define a variable. Explain the rues for writ Variable name in C8. How you declare vari in cH? ‘Ans. Variable Iris a data name which 1s ured w stor change during program © ‘name given 9 memory 10 data is stored. Rules for Variable Nas + At variable ae
You might also like
Visual Basic 1&2unit Notes SW 5th Sem.
PDF
No ratings yet
Visual Basic 1&2unit Notes SW 5th Sem.
80 pages
Java Telusko
PDF
100% (2)
Java Telusko
41 pages
Javascript Borad Paper Questions
PDF
No ratings yet
Javascript Borad Paper Questions
14 pages
Basic Functions of C Graphics
PDF
No ratings yet
Basic Functions of C Graphics
36 pages
Data Communication Computer Networks Notes BCA PDF
PDF
100% (2)
Data Communication Computer Networks Notes BCA PDF
20 pages
Pps - Question Bank
PDF
No ratings yet
Pps - Question Bank
65 pages
Bca 2ND Notes Programming in C++
PDF
100% (1)
Bca 2ND Notes Programming in C++
104 pages
ASP Net Question Paper
PDF
0% (1)
ASP Net Question Paper
122 pages
Bca 601
PDF
50% (2)
Bca 601
206 pages
CS Polytechnic Engineering-Oop With Java Semester 4 Text Books
PDF
No ratings yet
CS Polytechnic Engineering-Oop With Java Semester 4 Text Books
136 pages
Sharp Interview Questions
PDF
No ratings yet
Sharp Interview Questions
133 pages
Java 8 Programming Black Book
PDF
31% (36)
Java 8 Programming Black Book
2 pages
C# Iq
PDF
100% (1)
C# Iq
132 pages
JavaScript Notes PDF
PDF
67% (3)
JavaScript Notes PDF
19 pages
Dot Net FAQs
PDF
No ratings yet
Dot Net FAQs
34 pages
VisualStudio.net
PDF
No ratings yet
VisualStudio.net
22 pages
Java Notes
PDF
100% (3)
Java Notes
46 pages
Question Bank - C#
PDF
100% (1)
Question Bank - C#
16 pages
Practical File of Computer Networks
PDF
50% (2)
Practical File of Computer Networks
29 pages
Faqs
PDF
No ratings yet
Faqs
29 pages
Ssad Notes-Ii Bca
PDF
100% (1)
Ssad Notes-Ii Bca
68 pages
Web Design Notes For BCA 5th Sem 2019 PDF
PDF
No ratings yet
Web Design Notes For BCA 5th Sem 2019 PDF
44 pages
OOP Through C++ Notes - UNIT1
PDF
100% (1)
OOP Through C++ Notes - UNIT1
32 pages
CPP Hand Written Notes
PDF
100% (1)
CPP Hand Written Notes
55 pages
Java Programming and Dynamic Webpage Design
PDF
80% (10)
Java Programming and Dynamic Webpage Design
3 pages
Anatomy of Android
PDF
50% (2)
Anatomy of Android
2 pages
How Is The DLL Hell Problem Solved in
PDF
No ratings yet
How Is The DLL Hell Problem Solved in
12 pages
6th Java Sushil Goel
PDF
100% (2)
6th Java Sushil Goel
19 pages
OS Unit - 4 Notes
PDF
No ratings yet
OS Unit - 4 Notes
35 pages
Java Notes (Nep Syllabus)
PDF
100% (1)
Java Notes (Nep Syllabus)
133 pages
Constructors in Java
PDF
100% (1)
Constructors in Java
13 pages
Xii Important Questions With Solution Informatics Practices
PDF
75% (4)
Xii Important Questions With Solution Informatics Practices
12 pages
Javascript Exercise Answer
PDF
No ratings yet
Javascript Exercise Answer
10 pages
Java Notes
PDF
No ratings yet
Java Notes
202 pages
Java Practical File
PDF
No ratings yet
Java Practical File
13 pages
Unit 3 & 4 Os
PDF
No ratings yet
Unit 3 & 4 Os
19 pages
Object Modeling and C++ Programming For Bca 2nd Semester PDF
PDF
100% (2)
Object Modeling and C++ Programming For Bca 2nd Semester PDF
44 pages
5 Semester Bca Dot Net With C#
PDF
100% (1)
5 Semester Bca Dot Net With C#
7 pages
PC Software Notes Unit-I
PDF
No ratings yet
PC Software Notes Unit-I
4 pages
Java Tokens
PDF
No ratings yet
Java Tokens
68 pages
Introduction To Data Structures - BCA
PDF
100% (1)
Introduction To Data Structures - BCA
27 pages
State Identity and Behaviour of Objects
PDF
No ratings yet
State Identity and Behaviour of Objects
13 pages
Java Unit 3 Notes
PDF
No ratings yet
Java Unit 3 Notes
32 pages
Question Bank Object Oriented Programming and Methodology CSE-III Semester Unit-I
PDF
No ratings yet
Question Bank Object Oriented Programming and Methodology CSE-III Semester Unit-I
3 pages
Java - Inheritance ppt.1-1
PDF
No ratings yet
Java - Inheritance ppt.1-1
10 pages
Servlets Notes
PDF
100% (8)
Servlets Notes
18 pages
Cyber Ethics Notes
PDF
No ratings yet
Cyber Ethics Notes
7 pages
System Call and Its Type
PDF
No ratings yet
System Call and Its Type
4 pages
Java Handwritten Notes
PDF
100% (1)
Java Handwritten Notes
27 pages
Python Viva Questions and Answers
PDF
No ratings yet
Python Viva Questions and Answers
5 pages
Previous Year Solved Question Paper of
PDF
100% (1)
Previous Year Solved Question Paper of
12 pages
Sumita Arora Solved Exercise of Web Application Development
PDF
100% (6)
Sumita Arora Solved Exercise of Web Application Development
0 pages
10 Difference Between Single and Multiple Document Interface
PDF
No ratings yet
10 Difference Between Single and Multiple Document Interface
5 pages
Introduction To
PDF
No ratings yet
Introduction To
34 pages
Generation of OS
PDF
No ratings yet
Generation of OS
27 pages
Java Notes 12th Class
PDF
No ratings yet
Java Notes 12th Class
27 pages
Dot Net Interview
PDF
No ratings yet
Dot Net Interview
12 pages
Writing Code Compiling Code Generating Intermediate Language
PDF
No ratings yet
Writing Code Compiling Code Generating Intermediate Language
10 pages
Ai Abhishek Prasad
PDF
No ratings yet
Ai Abhishek Prasad
137 pages
Unit - 1 - C# - Chapter1
PDF
No ratings yet
Unit - 1 - C# - Chapter1
34 pages