The document contains questions and multiple choice answers about C# programming concepts.
Question 6 identifies a problem in a code snippet where a delegate is declared to accept a string parameter, but the methods passed to it do not. The correct code fixes this by removing the string parameter from the methods.
Question 20 asks which code snippet would correctly overload the unary minus operator to negate the values of two integer properties. The correct code negates the property values directly rather than using decrement operators.
Automatic assessment of code to support education is an important feature of many programming learning platforms. Unit testing frameworks can be used to perform a systematic functional test of codes; they are mainly used by developers. Competition graders can be used to safely execute code in sandboxed environments; they are mainly used for programming contests. This paper proposes a platform combining the advantages of unit testing and competition graders to provide a unit testing-based grader. The proposed platform assesses codes and produces relevant and "intelligent" feedbacks to support learning. The paper presents the architecture of the platform and how the unit tests are designed.
Club of anonimous developers "Refactoring: Legacy code"Victor_Cr
The document discusses various approaches to refactoring legacy code, including:
1. Migrating from an older build system (TOM) to a newer one (POM) by updating XML configuration files.
2. Introducing inversion of control (IoC) and dependency injection (DI) to reduce tight coupling in the code.
3. Implementing aspect-oriented programming (AOP) to separate cross-cutting concerns like transaction management and exception handling.
4. Updating older libraries to newer versions for performance improvements and richer APIs.
5. Cleaning up messy and difficult to read code through techniques like extracting methods and using regular expressions.
The Ring programming language version 1.6 book - Part 184 of 189Mahmoud Samir Fayed
This section provides an overview of the Ring programming language, including lists of its 49 keywords, 198 functions, common compiler errors, and the structure and instructions of its virtual machine (VM). The keywords include common ones like class, func, if, and while. The many functions cover strings, files, math, objects, and the VM. Compiler errors relate to missing elements like ok or end in control structures. The VM executes Ring code through its instructions and uses scopes and pointers to manage memory.
The document contains a sample code with multiple questions and answers related to Java programming. The questions cover topics like arrays, exceptions, object-oriented programming concepts, and more. The provided code snippets have compilation errors, runtime exceptions or produce specific output. The correct answers are explained to assess the understanding of Java programming concepts.
Creational Pattern of the design pattern.
Introducing 6 type patterns and also including the pros and cons. It's easy to understand what's kind of scenario it should be used.
TDD, BDD, ATDD are all methodologies that enable incremental design that is suitable for Agile environments. It seems that every day a new xDD methodology is born with the promise to be better than what came before. Should you use behaviour-driven tests or plain old unit tests? Which methodology is better? And how exactly would it benefit the development life cycle?
In this session, Dror will help to sort out the various methodologies – explaining where they came from, the tools they use, and discussing how and when to use each one. Here we will once and for all answer the question as to whether or not there’s one “DD” to rule them all.
The document discusses concurrency problems that arise with multi-core processors and large datasets. It examines options for handling concurrency like functional programming, Java's concurrency API, and thread-safe collections. Patterns for managing threads through thread pools and executors are presented. Examples show how to update shared values atomically to avoid race conditions. References are provided for further reading on Java concurrency.
Introduction to web programming for java and c# programmers by @drpicoxDavid Rodenas
(better presented by @drpicox)
Slides of an introductory course for web programming focusing in basic Javascript and CSS concepts. It assumes knowledge of programming, Java or C#.
Automatic assessment of code to support education is an important feature of many programming learning platforms. Unit testing frameworks can be used to perform a systematic functional test of codes; they are mainly used by developers. Competition graders can be used to safely execute code in sandboxed environments; they are mainly used for programming contests. This paper proposes a platform combining the advantages of unit testing and competition graders to provide a unit testing-based grader. The proposed platform assesses codes and produces relevant and "intelligent" feedbacks to support learning. The paper presents the architecture of the platform and how the unit tests are designed.
Club of anonimous developers "Refactoring: Legacy code"Victor_Cr
The document discusses various approaches to refactoring legacy code, including:
1. Migrating from an older build system (TOM) to a newer one (POM) by updating XML configuration files.
2. Introducing inversion of control (IoC) and dependency injection (DI) to reduce tight coupling in the code.
3. Implementing aspect-oriented programming (AOP) to separate cross-cutting concerns like transaction management and exception handling.
4. Updating older libraries to newer versions for performance improvements and richer APIs.
5. Cleaning up messy and difficult to read code through techniques like extracting methods and using regular expressions.
The Ring programming language version 1.6 book - Part 184 of 189Mahmoud Samir Fayed
This section provides an overview of the Ring programming language, including lists of its 49 keywords, 198 functions, common compiler errors, and the structure and instructions of its virtual machine (VM). The keywords include common ones like class, func, if, and while. The many functions cover strings, files, math, objects, and the VM. Compiler errors relate to missing elements like ok or end in control structures. The VM executes Ring code through its instructions and uses scopes and pointers to manage memory.
The document contains a sample code with multiple questions and answers related to Java programming. The questions cover topics like arrays, exceptions, object-oriented programming concepts, and more. The provided code snippets have compilation errors, runtime exceptions or produce specific output. The correct answers are explained to assess the understanding of Java programming concepts.
Creational Pattern of the design pattern.
Introducing 6 type patterns and also including the pros and cons. It's easy to understand what's kind of scenario it should be used.
TDD, BDD, ATDD are all methodologies that enable incremental design that is suitable for Agile environments. It seems that every day a new xDD methodology is born with the promise to be better than what came before. Should you use behaviour-driven tests or plain old unit tests? Which methodology is better? And how exactly would it benefit the development life cycle?
In this session, Dror will help to sort out the various methodologies – explaining where they came from, the tools they use, and discussing how and when to use each one. Here we will once and for all answer the question as to whether or not there’s one “DD” to rule them all.
The document discusses concurrency problems that arise with multi-core processors and large datasets. It examines options for handling concurrency like functional programming, Java's concurrency API, and thread-safe collections. Patterns for managing threads through thread pools and executors are presented. Examples show how to update shared values atomically to avoid race conditions. References are provided for further reading on Java concurrency.
Introduction to web programming for java and c# programmers by @drpicoxDavid Rodenas
(better presented by @drpicox)
Slides of an introductory course for web programming focusing in basic Javascript and CSS concepts. It assumes knowledge of programming, Java or C#.
This document discusses effective practices for dependency injection (DI). It begins with a quick DI refresher and then provides guidelines for DI such as: explicitly defining dependencies, injecting exactly what is needed, preferring constructor injection, avoiding work in constructors, and avoiding direct dependencies on the injector. It also discusses testing code using DI, applying DI to existing code, and techniques for migrating code to use DI such as bottom-up or top-down approaches.
Design pattern part 2 - structural patternJieyi Wu
This is first part: https://www.slideshare.net/JieyiWu1/design-pattern-part-1-81195876
Structural Pattern is introducing 7 type patterns and also including the pros and cons to you.
Behavioral Pattern of the design pattern.
Introducing 6 type patterns and also including the pros and cons. It's easy to understand what's kind of scenario it should be used.
Использование GMock для обеспечения спокойной и сытой жизни разработчика. Обзор как верхушки так и некоторых подводных частей GMock. Разбор возможностей фреймворка на примерах.
The document discusses principles of writing clean code through perspectives from different authors. It emphasizes that clean code is readable, maintainable with minimal dependencies, well-tested, has meaningful names, focuses on doing one thing well with minimal lines of code per function. Comments should explain intent rather than make up for poor code quality. Function arguments, switch statements, and comments should be used judiciously.
The document discusses various object-oriented programming concepts in Java including inheritance, subclasses, overriding methods, constructors, and modifiers for classes, variables, constructors, and methods. It provides examples to demonstrate inheritance hierarchies, accessing variables and methods from superclasses, constructor invocation order, abstract classes, and usage of access modifiers like public, private, and protected.
The Ring programming language version 1.7 book - Part 92 of 196Mahmoud Samir Fayed
The document provides information about the Ring programming language including language keywords, functions, compiler errors, runtime errors, and environment errors.
It lists the 49 keywords used in Ring such as class, def, else, func, if, new, etc. It also lists 199 language functions organized alphabetically from add() to ring_state_setvar().
26 potential compiler errors are described that may occur during compilation such as errors in parameters, class names, missing brackets or parentheses. 15 runtime errors are also listed that could happen during execution like divide by zero, out of bounds array access, or calling undefined functions.
The document serves as a reference for the core components of the Ring language specification including the syntax rules
The document contains 12 code snippets with multiple choice questions about Java concepts like threads, collections, serialization, patterns, and more. For each code snippet, 4 possible outputs are provided to choose from as the answer. The correct answers are also provided with brief explanations.
This document provides an overview of the Dart programming language created by Google. It discusses Dart's structure as a new programming language with its own runtime environment and tools. Key features covered include Dart's static yet dynamic typing, use of classes and objects, namespaces, isolates for concurrency, and snapshots for faster startups. The document also provides code examples demonstrating Dart's syntax and how it handles concepts like generics differently than other languages like Java.
This presentation introduces some advanced concepts of generics in Java. These slides introduce the following concepts:
- Generic classes and methods
- Type variable bounds
- Type erasure process
- Generics and inheritance
- Wildcard types
The presentation is took from the Java course I run in the bachelor-level informatics curriculum at the University of Padova.
The document discusses collections in C# programming. It shows examples of using List and Dictionary collections to store and retrieve data. A List is used to store integer values and later iterate through them. A Dictionary is used to store Customer objects mapped by ID. The document also demonstrates converting between collection types using ConvertAll and a custom converter.
This document provides an overview of test driven development (TDD). It defines TDD as first writing an initially failing test case that defines a requirement, then producing just enough code to pass that test, and refactoring the new code. The document outlines the basic TDD steps, what can be tested, advantages of TDD like improved design and reduced bugs, and provides an example of incrementally developing a method using TDD.
Virtual functions allow dynamic binding to occur. This means that the function called is determined at runtime based on the actual object type, rather than static binding which determines the function at compile time. Some key points:
1) A virtual function tells the compiler to create a pointer to the function but not fill it in until called.
2) Classes with virtual functions are called polymorphic classes and allow overriding derived class functions.
3) Virtual functions are useful for polymorphism when subclasses need to provide unique implementations of the same method name.
The document discusses delegates, events, and lambda expressions in C# for implementing callback methods. It provides examples of using delegates to define callback method signatures, attaching methods to events using delegates, and using lambda expressions as an anonymous way to work with delegates. Key examples include registering and unregistering callback methods for a teacher class using delegates and events, and showing how lambda expressions can simplify this.
RxJava и Android. Плюсы, минусы, подводные камниStfalcon Meetups
Ярослав Герьятович
Android Engineer в компании Attendify . Спикер на UA Mobile'14 . Идеолог функционального и реактивного подхода в проектировании Android приложений.
The document discusses several advanced programming topics including multithreaded applications, delegates, inheritance, and interfaces in C#. It provides examples of creating and running multithreaded applications using the Thread class. It also demonstrates how to use delegates to reference and call methods indirectly, and how to handle thread synchronization issues in multithreaded programs. The document explains inheritance in C# and compares overriding and hiding. It defines what interfaces are and how they allow for multiple inheritance by defining method signatures without implementations.
The Ring programming language version 1.10 book - Part 102 of 212Mahmoud Samir Fayed
This document discusses Ring's architecture and memory management.
Ring applications are written in Ring and use Ring libraries and extensions. Ring libraries are written in Ring, while extensions are dynamic libraries written in C/C++ that interface with the Ring Virtual Machine (VM). The VM is written in C and runs on the host operating system.
Ring uses scope-based memory management. When a function is called, a new scope is created. Variables declared within the function exist only within this scope and are destroyed when the function exits. Ring also uses reference counting for memory management of objects.
The Ring programming language version 1.8 book - Part 92 of 202Mahmoud Samir Fayed
Here are the key differences between Ring and Python:
- Paradigms: Ring supports multiple paradigms like procedural, object-oriented, functional and declarative programming. It aims to better integrate these paradigms compared to Python. Python is mainly object-oriented with some functional features.
- Type System: Ring is weakly typed while Python is dynamically typed. Ring does automatic type conversions in some cases for convenience.
- Performance: Ring aims to be faster than Python by using a bytecode VM and optimizations like escape analysis in its garbage collector. Python relies more on interpretation.
- Natural Language: Ring puts more emphasis on natural language programming constructs to make programming more intuitive and language-like. This is not a major focus
The document discusses virtual functions, which allow for polymorphism in C++ by implementing the "one interface, multiple methods" philosophy. A virtual function declared in a base class can be overridden in derived classes. Abstract base classes contain at least one pure virtual function and cannot be instantiated. Virtual base classes are used to resolve issues that can arise with multiple inheritance. Friend functions can access private members of classes they are declared as friends to.
This document describes the design of an object-oriented programming language. It discusses:
1) The basic structure of programs as blocks of expressions that enrich the environment. Classes, objects, and procedures are all treated as values.
2) The abstract syntax for expressions including class and object creation, field and method declaration, inheritance, and cloning.
3) How values are represented, including objects, entries for fields/methods, and procedures. Inheritance is implemented by copying fields and methods.
4) Data structures like objects and entries that represent values. Inheritance works by finding fields/methods in superclasses and copying them.
The document contains questions and multiple choice answers about C# programming concepts such as access specifiers, exceptions, delegates, operators, assemblies, and deployment projects.
The document discusses constructors and destructors in C++ classes. It provides examples of constructor definitions and errors. It explains the purpose and behavior of default, parameterized, and copy constructors. It also discusses the characteristics and purpose of constructors and destructors.
This document discusses effective practices for dependency injection (DI). It begins with a quick DI refresher and then provides guidelines for DI such as: explicitly defining dependencies, injecting exactly what is needed, preferring constructor injection, avoiding work in constructors, and avoiding direct dependencies on the injector. It also discusses testing code using DI, applying DI to existing code, and techniques for migrating code to use DI such as bottom-up or top-down approaches.
Design pattern part 2 - structural patternJieyi Wu
This is first part: https://www.slideshare.net/JieyiWu1/design-pattern-part-1-81195876
Structural Pattern is introducing 7 type patterns and also including the pros and cons to you.
Behavioral Pattern of the design pattern.
Introducing 6 type patterns and also including the pros and cons. It's easy to understand what's kind of scenario it should be used.
Использование GMock для обеспечения спокойной и сытой жизни разработчика. Обзор как верхушки так и некоторых подводных частей GMock. Разбор возможностей фреймворка на примерах.
The document discusses principles of writing clean code through perspectives from different authors. It emphasizes that clean code is readable, maintainable with minimal dependencies, well-tested, has meaningful names, focuses on doing one thing well with minimal lines of code per function. Comments should explain intent rather than make up for poor code quality. Function arguments, switch statements, and comments should be used judiciously.
The document discusses various object-oriented programming concepts in Java including inheritance, subclasses, overriding methods, constructors, and modifiers for classes, variables, constructors, and methods. It provides examples to demonstrate inheritance hierarchies, accessing variables and methods from superclasses, constructor invocation order, abstract classes, and usage of access modifiers like public, private, and protected.
The Ring programming language version 1.7 book - Part 92 of 196Mahmoud Samir Fayed
The document provides information about the Ring programming language including language keywords, functions, compiler errors, runtime errors, and environment errors.
It lists the 49 keywords used in Ring such as class, def, else, func, if, new, etc. It also lists 199 language functions organized alphabetically from add() to ring_state_setvar().
26 potential compiler errors are described that may occur during compilation such as errors in parameters, class names, missing brackets or parentheses. 15 runtime errors are also listed that could happen during execution like divide by zero, out of bounds array access, or calling undefined functions.
The document serves as a reference for the core components of the Ring language specification including the syntax rules
The document contains 12 code snippets with multiple choice questions about Java concepts like threads, collections, serialization, patterns, and more. For each code snippet, 4 possible outputs are provided to choose from as the answer. The correct answers are also provided with brief explanations.
This document provides an overview of the Dart programming language created by Google. It discusses Dart's structure as a new programming language with its own runtime environment and tools. Key features covered include Dart's static yet dynamic typing, use of classes and objects, namespaces, isolates for concurrency, and snapshots for faster startups. The document also provides code examples demonstrating Dart's syntax and how it handles concepts like generics differently than other languages like Java.
This presentation introduces some advanced concepts of generics in Java. These slides introduce the following concepts:
- Generic classes and methods
- Type variable bounds
- Type erasure process
- Generics and inheritance
- Wildcard types
The presentation is took from the Java course I run in the bachelor-level informatics curriculum at the University of Padova.
The document discusses collections in C# programming. It shows examples of using List and Dictionary collections to store and retrieve data. A List is used to store integer values and later iterate through them. A Dictionary is used to store Customer objects mapped by ID. The document also demonstrates converting between collection types using ConvertAll and a custom converter.
This document provides an overview of test driven development (TDD). It defines TDD as first writing an initially failing test case that defines a requirement, then producing just enough code to pass that test, and refactoring the new code. The document outlines the basic TDD steps, what can be tested, advantages of TDD like improved design and reduced bugs, and provides an example of incrementally developing a method using TDD.
Virtual functions allow dynamic binding to occur. This means that the function called is determined at runtime based on the actual object type, rather than static binding which determines the function at compile time. Some key points:
1) A virtual function tells the compiler to create a pointer to the function but not fill it in until called.
2) Classes with virtual functions are called polymorphic classes and allow overriding derived class functions.
3) Virtual functions are useful for polymorphism when subclasses need to provide unique implementations of the same method name.
The document discusses delegates, events, and lambda expressions in C# for implementing callback methods. It provides examples of using delegates to define callback method signatures, attaching methods to events using delegates, and using lambda expressions as an anonymous way to work with delegates. Key examples include registering and unregistering callback methods for a teacher class using delegates and events, and showing how lambda expressions can simplify this.
RxJava и Android. Плюсы, минусы, подводные камниStfalcon Meetups
Ярослав Герьятович
Android Engineer в компании Attendify . Спикер на UA Mobile'14 . Идеолог функционального и реактивного подхода в проектировании Android приложений.
The document discusses several advanced programming topics including multithreaded applications, delegates, inheritance, and interfaces in C#. It provides examples of creating and running multithreaded applications using the Thread class. It also demonstrates how to use delegates to reference and call methods indirectly, and how to handle thread synchronization issues in multithreaded programs. The document explains inheritance in C# and compares overriding and hiding. It defines what interfaces are and how they allow for multiple inheritance by defining method signatures without implementations.
The Ring programming language version 1.10 book - Part 102 of 212Mahmoud Samir Fayed
This document discusses Ring's architecture and memory management.
Ring applications are written in Ring and use Ring libraries and extensions. Ring libraries are written in Ring, while extensions are dynamic libraries written in C/C++ that interface with the Ring Virtual Machine (VM). The VM is written in C and runs on the host operating system.
Ring uses scope-based memory management. When a function is called, a new scope is created. Variables declared within the function exist only within this scope and are destroyed when the function exits. Ring also uses reference counting for memory management of objects.
The Ring programming language version 1.8 book - Part 92 of 202Mahmoud Samir Fayed
Here are the key differences between Ring and Python:
- Paradigms: Ring supports multiple paradigms like procedural, object-oriented, functional and declarative programming. It aims to better integrate these paradigms compared to Python. Python is mainly object-oriented with some functional features.
- Type System: Ring is weakly typed while Python is dynamically typed. Ring does automatic type conversions in some cases for convenience.
- Performance: Ring aims to be faster than Python by using a bytecode VM and optimizations like escape analysis in its garbage collector. Python relies more on interpretation.
- Natural Language: Ring puts more emphasis on natural language programming constructs to make programming more intuitive and language-like. This is not a major focus
The document discusses virtual functions, which allow for polymorphism in C++ by implementing the "one interface, multiple methods" philosophy. A virtual function declared in a base class can be overridden in derived classes. Abstract base classes contain at least one pure virtual function and cannot be instantiated. Virtual base classes are used to resolve issues that can arise with multiple inheritance. Friend functions can access private members of classes they are declared as friends to.
This document describes the design of an object-oriented programming language. It discusses:
1) The basic structure of programs as blocks of expressions that enrich the environment. Classes, objects, and procedures are all treated as values.
2) The abstract syntax for expressions including class and object creation, field and method declaration, inheritance, and cloning.
3) How values are represented, including objects, entries for fields/methods, and procedures. Inheritance is implemented by copying fields and methods.
4) Data structures like objects and entries that represent values. Inheritance works by finding fields/methods in superclasses and copying them.
The document contains questions and multiple choice answers about C# programming concepts such as access specifiers, exceptions, delegates, operators, assemblies, and deployment projects.
The document discusses constructors and destructors in C++ classes. It provides examples of constructor definitions and errors. It explains the purpose and behavior of default, parameterized, and copy constructors. It also discusses the characteristics and purpose of constructors and destructors.
This document discusses interfaces in Java, including defining interfaces, implementing interfaces, and providing examples. It covers that an interface defines a collection of methods that a class implements, concrete classes that implement interfaces must provide code bodies for all interface methods, and interfaces allow for multiple inheritance in Java by having classes implement multiple interfaces.
The document contains 27 C# programs demonstrating various concepts in C# programming such as: getting user input and performing calculations; defining methods within classes; using instance variables; static variables and methods; inheritance; namespaces; constructors; destructors; method overloading and overriding; and the 'this' keyword. The programs cover basic to more advanced C# programming concepts.
Dependency Injection for Android @ Ciklum speakers corner Kiev 29. May 2014First Tuesday Bergen
We are happy to invite you to the Speakers’ Corner today, on Thursday May 29, from 18.30 till 19.30 at SkyPoint to meet Thomas Vervik, Head of Development Bipper Communications who will talk on “How to save money on QA - Dependency Injection and automated testing on Android”
Thomas is Head of Development for Bipper Communications, and has been managing the company's team in Kiev since February 2012. Originally a seasoned Java server backend/frontend developer, he has the last two years started mobile development, first with HTML 5 and later Android.
Mobile development has since its birth around 2008 gone from simple apps to more complex enterprise similar software. The increase in size and complexity yields the need for structuring the code differently in order to handle the new complexity. The tools used to handle this complexity has been applied to server side development for years, but mobile development has been lagging behind.
But not anymore. New frameworks built on proven paradigms are emerging, and in this Speakers Corner we will introduce Dependency Injection for Android, the motivation for its use, and one of the implementations - Dagger. Dependency Injection has several advantages, but in this presentation we will focus on how it enables to write proper automated tests.
We are happy to invite you to the Speakers’ Corner today, on Thursday May 29, from 18.30 till 19.30 at SkyPoint to meet Thomas Vervik, Head of Development Bipper Communications who will talk on “How to save money on QA - Dependency Injection and automated testing on Android”
Thomas is Head of Development for Bipper Communications, and has been managing the company's team in Kiev since February 2012. Originally a seasoned Java server backend/frontend developer, he has the last two years started mobile development, first with HTML 5 and later Android.
Mobile development has since its birth around 2008 gone from simple apps to more complex enterprise similar software. The increase in size and complexity yields the need for structuring the code differently in order to handle the new complexity. The tools used to handle this complexity has been applied to server side development for years, but mobile development has been lagging behind.
But not anymore. New frameworks built on proven paradigms are emerging, and in this Speakers Corner we will introduce Dependency Injection for Android, the motivation for its use, and one of the implementations - Dagger. Dependency Injection has several advantages, but in this presentation we will focus on how it enables to write proper automated tests.
The document discusses several design patterns including strategy, template method, factory method, command, state, null object, and dependency injection. It provides examples of how each pattern can be implemented in code by defining interfaces and classes that implement the pattern. The examples demonstrate how different design patterns address common programming problems by organizing code in a reusable and flexible manner.
Interfaces define methods that classes can implement. Classes implementing interfaces must define all interface methods. Interfaces can extend other interfaces, requiring implementing classes to define inherited methods as well. Interface variables are implicitly public, static, and final. A class can implement multiple interfaces and override methods with the same name across interfaces. Partial interface implementation requires the class to be abstract.
This document summarizes key concepts in object-oriented programming including:
1) Primitive types like int, long, float, double, char arrays, and boolean that are similar to C primitives.
2) Boxed types that wrap primitive types in objects like Integer and Long.
3) Type conversion between primitives and objects.
4) Strings are objects that can be concatenated or modified.
5) Methods can be static or require an object instance. Constructors are special methods that initialize objects.
6) Access modifiers like public, private, and protected control the scope of classes, methods, and variables.
The document discusses exception handling in C# programs. It explains that exceptions are errors that occur during program execution. The C# try, catch, and finally keywords are used to handle exceptions. The try block contains code that might cause exceptions. The catch block handles specific exception types. The finally block contains cleanup code that always executes. Built-in exceptions like DivideByZeroException are part of the .NET Framework. Exception handling prevents program crashes and allows graceful handling of errors.
The document discusses different types of data members and member functions in classes in C++, including constant, mutable, and static data members, as well as constant, static, overloaded, and inline member functions. It provides examples of how to declare and use these various data members and member functions. It also covers topics like constant member functions, static data members, nested member functions, friend functions and classes, array of objects, and passing objects to functions by value, reference, and pointer.
This document provides an overview of key object-oriented programming concepts including classes and objects, inheritance, encapsulation, polymorphism, interfaces, abstract classes, and design patterns. It discusses class construction and object instantiation. Inheritance is described as both exposing implementation details and potentially breaking encapsulation. Composition is presented as an alternative to inheritance. The document also covers method overriding, overloading, and duck typing as forms of polymorphism. Finally, it briefly introduces common design principles like SOLID and patterns like delegation.
Here we are going to learn why is a good practice to use interfaces and how they are different from abstraction classes. Further more we are going to see how which one of them to use.
C# .NET: Language Features and Creating .NET Projects, Namespaces Classes and...yazad dumasia
C# .NET: Language Features and Creating .NET Projects, Namespaces Classes and Inheritance , Exploring the Base Class Library -, Debugging and Error Handling , Data Types full knowledge about basic of .NET Framework
This document provides a manual for a Java and J2EE lab for 5th semester computer science students. It contains 15 programs covering topics like enums, annotations, collections, strings, servlets, and database connectivity. Each program is explained and the expected output is provided. The programs demonstrate core Java concepts and commonly used APIs for collections, strings, I/O, and database access.
100% Accurate and Updated dumps available for 1Z0-804 Exam-Java SE 7 Programmer II get 20% off on all dumps visit@https://www.troytec.com/1Z0-804-exams.html
Pro typescript.ch03.Object Orientation in TypeScriptSeok-joon Yun
The document discusses object-oriented programming concepts in TypeScript such as classes, inheritance, polymorphism, and mixins. It provides code examples of implementing interfaces and classes to demonstrate inheritance and composition. Mixins are discussed as a way to reuse behavior across class hierarchies by applying multiple base classes to a derived class using a mixin function. The examples show how to define mixin behaviors as classes and apply them to implementing classes to achieve multiple inheritance in TypeScript.
The document provides examples of code snippets in C# to demonstrate various OOP concepts like inheritance, polymorphism, delegates, constructors, exception handling, file I/O, and adding a flash item to a website. It also explains XML and DTDs. The code snippets show how to implement inheritance by defining a base Shape class and derived Rectangle class, implement polymorphism by overloading a print method, use delegates to call methods, define default and parameterized constructors, handle exceptions, perform file read/write operations, and add a flash file to an HTML document. The explanation of XML covers internal and external DTD declarations to define document structure.
This document discusses principles of object oriented programming including encapsulation, abstraction, inheritance, polymorphism, and decoupling. It provides examples of classes, objects, methods, and interfaces. It also explains SOLID principles such as the single responsibility principle, open/closed principle, Liskov substitution principle, interface segregation principle, and dependency injection.
1. Test Engine Q3 Soft
1. What is the purpose of public access specifier? (1đ)
A. The public access specifier allows a class to hide its member variables
and member functions from other class objects and functions.
B. The public access specifier allows a class to
expose its member variables and member functions to
other function and objects.
C. The public access specifier allows a class to show its member variables
and member functions to the containing class, derived classes, or to
classes within the same application.
D. The public access specifier allows a class to hide its member variables
and member functions from other class objects and functions, except the
child class.
2. What is realistic modeling? (1đ)
A. Realistic modeling is the approach to model the
real world more accurately.
B. Realistic modeling is the approach to exist in different forms.
C. Realistic modeling is the approach to allow systems to evolve.
D. Realistic modeling is the approach of using existing classes or objects
from other applications.
3. John has written a program in C# to store a list of random
numbers in an array of size 10. During program execution, John
tries to enter an 11th element in the array. Identify the type of
exception the system would have thrown. (2đ)
A. System.IndexOutOfRangeException
B. System.DividedByZeroException
C. System.NullReferenceException
D. System.OutOfMemoryException
4. What is the purpose of the member, Appentd, in the FileMode
enumerator? (1đ)
A. It always creates a new file.
2. B. It opens the file if it exists and places the
cursor at the end of file, or creates a new file.
C. It opens only existing file.
D. It opens the file if it exists and places the cursor at the beginning
of file.
5. Which of the following does NOT hold true for a delegate? (1đ)
A. The methods that can be referenced by a delegate are determined by the
delegate declaration.
B. A multicast delegate derives from the
System.MulticastDelegate class.
C. A delegate is a reference type variable, which holds the reference to a
method.
D. A single-cast delegate contains an invocation list of
multiple methods.
6. Consider the following code snippet: (4đ)
public class Test
{
public delegate void myDelegate(String s);
public static void accept(string str)
{
Console.WriteLine("{0} accept() function", str);
//Implementation
}
public static void show()
{
//Implementation
}
public static void display(myDelegate PMethod)
{
PMethod("This is in the");
}
public static void Main()
{
myDelegate d1 = new myDelegate(accept);
myDelegate d2 = new myDelegate(show);
display(d1);
display(d2);
}
}
There is some problem in the preceding code snippet. Identify the
problem and provide the correct code snippet.
3. A. public class Test
{
public delegate void myDelegate(String s);
public static string accept(string str)
{
Console.WriteLine("{0} accept() function", str);
return str;
}
public static string show(string str)
{
Console.WriteLine("{0} display() function", str);
return str;
}
public static void display(myDelegate PMethod)
{
PMethod("This is in the");
}
public static void Main()
{
myDelegate d1 = new myDelegate(accept);
myDelegate d2 = new myDelegate(show);
display(d1);
display(d2);
}
}
B. public class Test
{
public delegate void myDelegate();
public static void accept(string str)
{
Console.WriteLine("{0} accept() function", str);
//Implementation
}
public static void show(string str)
{
Console.WriteLine("{0} display() function", str);
//Implementation
}
public static void display(myDelegate PMethod)
{
PMethod("This is in the");
}
public static void Main()
{
myDelegate d1 = new myDelegate(accept);
myDelegate d2 = new myDelegate(show);
display(d1);
display(d2);
}
}
C. public class Test
{
4. public delegate void myDelegate(String s);
public static void accept(string str)
{
Console.WriteLine("{0} accept()
function", str);
//Implementation
}
public static void show(string str)
{
Console.WriteLine("{0} display()
function", str);
//Implementation
}
public static void display(myDelegate
PMethod)
{
PMethod("This is in the");
}
public static void Main()
{
myDelegate d1 = new myDelegate(accept);
myDelegate d2 = new myDelegate(show);
display(d1);
display(d2);
}
}
D. public class Test
{
public delegate void myDelegate(String s);
public static void accept()
{
//Implementation
}
public static void show()
{
//Implementation
}
public static void display(myDelegate PMethod)
{
PMethod("This is in the");
}
public static void Main()
{
myDelegate d1 = new myDelegate(accept);
myDelegate d2 = new myDelegate(show);
5. display(d1);
display(d2);
}
}
7. Which of the following does NOT hold true for constructor? (1đ)
A. Instance constructors are used to initialize data members of the class
B. Static constructors are used to initialize non-
static variables of a class
C. Static constructors have an implicit private access.
D. Instance constructor is called whenever an instance of a class is
created
8. Consider the following code: (4đ)
class Test
{
public Test()
{
}
public Test(string name)
{
Console.WriteLine("Hello" + name);
}
}
class myClass : Test
{
public myClass(int age)
: base("Sam")
{
Console.WriteLine("Your age is " + age);
}
public myClass(string book)
{
Console.WriteLine("Your favourite book is " + book);
}
public static void Main()
{
myClass obj1 = new myClass(17);
myClass obj2 = new myClass("The trail of years");
}
}
Identify the output of the preceding code.
Hello Sam
Your age is 17
6. Your favorite book is The trail of years
Your age is 17
Your favorite book is The trail of years
Hello Sam
Your age is 17
Your favorite book is The trail of years
Hello Sam
9. John has to create an application in which he needs to create a
user-defined exception class CustomerRecordNotFoundException. In
the CustomerRecordNotFoundException class, he has to declare two
constructors with different parameters. Which of the following
code snippet he should use for this purpose? (4đ)
using System;
public class CustomerRecordNotFoundException : Exception
{
public CustomerRecordFoundException()
{
}
public CustomerRecordNotFoundException(string message) :
base(message)
{
}
}
public CustomerRecordNotFoundException :
ApplicationException
{
public CustomerRecordNotFound()
{
}
7. public CustomerRecordNotFound(string message) :
base(message)
{
}
}
public class CustomerRecordNotFoundException : ApplicationException
{
public CustomerRecordNotFoundException()
{
}
public CustomerRecordNotFoundException(string message) :
Exception(message)
{
}
}
public class CustomerRecordNotFoundException : ApplicationException
{
public CustomerRecordNotFoundException()
{
}
public CustomerRecordNotFoundException(string message) :
Exception(message)
{
}
}
10. Mary has to write a program in which she wants all the
variables of a class to be accessible only within that class and
its sub classes. Which of the following access specifier should
Mary use to accomplish this task? (2đ)
A. Public
B. Internal
C. Private
D. Protected
11. Anna needs to write code in C# to work with a file named
Test.txt. According to the requirement, the Test.txt file should
get opened as soon as the program starts executing. If Test.txt
does not already exist, a new file with the same name should get
created. However, if the file exists, she needs to ensure that
8. the pointer is at the beginning of the file. Identify the correct
code snippet that would enable Anna to accomplish this task. (3đ)
FileStream fs = new FileStream("Test.txt", FileMode.OpenOrCreate,
FileAccess.ReadWrite);
StreamReader sr = new StreamReader(fs);
sr.BaseStream.Seek(0, SeekOrigin.End);
string struct = sr.ReadLine();
FileStream fs = new FileStream("Test.txt",
FileMode.OpenOrCreate, FileAccess.ReadWrite);
StreamReader sr = new StreamReader(fs);
sr.BaseStream.Seek(0, SeekOrigin.Begin);
string struct = sr.ReadLine();
FileStream fs = new FileStream("Test.txt", FileMode.Open,
FileAccess.ReadWrite);
StreamReader sr = new StreamReader(fs);
sr.BaseStream.Seek(0, SeekOrigin.Begin);
string struct = sr.ReadLine();
FileStream fs = new FileStream("Test.txt", FileMode.CreateNew,
FileAccess.ReadWrite);
StreamReader sr = new StreamReader(fs);
sr.BaseStream.Seek(0, SeekOrigin.Begin);
string struct = sr.ReadLine();
12. Which of the following is a logical operator? (1đ)
A. &
B. ++
C. ==
D. /=
13. John wants to write a program in C# to display a list of
first n natural numbers. The total numbers of natural numbers to
be displayed needs to be accepted from the user. Identify the
correct code that would enable John to accomplish his task. (3đ)
A. class Numbers
{
public int range;
public void Accept()
{
Console.WriteLine("Enter the range: ");
range = Convert.ToInt32(Console.ReadLine());
}
public void Display()
{
for (int i = 1; i <= range; i++)
9. {
Console.Write(i + "t");
}
}
public static void Main(string[] args)
{
Numbers obj = new Numbers();
Numbers.Accept();
Numbers.Display();
}
}
B. class Numbers
{
public int range;
public void Accept()
{
Console.WriteLine("Enter the range: ");
range =
Convert.ToInt32(Console.ReadLine());
}
public void Display()
{
for (int i = 1; i <= range; i++)
{
Console.Write(i + "t");
}
}
public static void Main(string[] args)
{
Numbers obj = new Numbers();
obj.Accept();
obj.Display();
}
}
C. class Numbers
{
public int range;
public void Accept()
{
Console.WriteLine("Enter the range: ");
range = Convert.ToInt32(Console.ReadLine());
}
10. public void Display()
{
for (int i = 1; i <= range; i++)
{
Console.Write(i + "t");
}
}
public static void Main(string[] args)
{
Accept();
Display();
}
}
D. class Numbers
{
public int range;
public void Accept()
{
Console.WriteLine("Enter the range: ");
range = Convert.ToInt32(Console.ReadLine());
}
public void Display()
{
for (int i = 1; i <= range; i++)
{
Console.Write(i + "t");
}
}
public static void Main(string[] args)
{
Numbers obj = new Numbers();
Accept();
Display();
}
}
14. Consider the following code snippet: (2đ)
class Medicine
{
public static void Main(string[] args)
{
string lMedicine_Name;
double Medicine_Price;
Console.WriteLine("Enter the name of the medicine: ");
lMedicine_Name = Console.ReadLine();
Console.WriteLine("The price of the medicine is Rs.50");
Console.ReadLine();
}
}
11. When the preceding code is executed, it show error. Identify the error
in the preceding code.
A. The data type used with the variable Medicine_Price is invalid
B. The variable lMedicine_Name is invalid
C. The variable Medicine_Price is invalid
D. The data type used with the variable lMedicine_Name is invalid
15.Which data type can be used for a variable that stores the grade
of a student in a particular exam, where the grades can be A, B,
or C? (1đ)
A. int
B. char[]
C. char
D. float
16. Which of the section handlers, used by the .NET Framework,
return a hash table containing name/value settings ? (1đ)
A. SingleTagSectionHandler
B. IgnoreSectionHandler
C. DictionarySectionHandler
D. NameValueSectionHandler
17. You are creating a deployment project. You want to add a
registry to the deployment project by using Registry Editor.
Which of the following option provides the correct setps to add a
registry key to the deployment project ? (3đ)10.20
1.Select View Editor Registry to open the Registry
Editor.
2.Select one of the top-level key nodes in the Registry
Editor.
3.Select Action New Key to create a New Key node in
the selected top-level key node.
4. Specify the name of the key by setting the Name
property in the Properties window.
12. 1.Select View File System Registry to open the Registry Editor.
2.Select one of the top-level key nodes in the Registry Editor.
3.Select Action New Key to create a New Key node in the selected top-level
key node.
4.Specify the name of the key by setting the KeyName property in the
Properties window.
1.Select View File System Registry to open the Registry Editor.
2.Select one of the top-level key nodes in the Registry Editor.
3.Select Action New Key to create a New Key node in the selected top-
level key node.
4.Specify the name of the key by setting the Name property in the Properties
window.
1.Select View File System Registry to open the Registry Editor.
2.Select one of the top-level key nodes in the Registry Editor.
3.Select Action New Key to create a New Key node in the selected top-
level key node.
4.Specify the name of the key by setting the Name property in the Properties
window.
18. Consider the following two statements: (2đ)
A.Major version number of an assembly gets changed while adding a
new class or a new project.
B.Minor version number of an assembly gets changed when a module
or function is added to the project.
Which of the following option is correct with regard to the above
mentioned statements ?
A. Both A and B are True.
B. Both A and B are False.
13. C. A False and B True.
D. A True and B False.
19. ________ template is used to create a single package
containing all the files, resources, registry entries, and the
setup logic necessary for deploying a component. (1đ)
A. Cab Project
B. Setup Project
C. Merge Module Project
D. Web Setup Project
20. Consider the following code which is written to overload a
unary operator: (3đ)
using System;
namespace p
{
class opr
{
public int a, b;
public opr(int x, int y)
{
a = x;
b = y;
}
public static opr operator -(opr o)
{
o.a- = o.a;
o.b- = o.b;
return o;
}
public void display()
{
Console.WriteLine("a=" + a);
Console.WriteLine("b=" + b;
Console.ReadLine();
}
}
class opr.override
{
static void Main()
{
opr obj = new opr(2, -5);
obj = -obj;
obj.display();
}
14. }
}
When the code is executed, it displays the result 0,0. It should
display the result -2.5. Which of the following code will solve this
problem?
public static opr operator -(opr o)
{
o.a = -o.a;
o.b = -o.b;
return o;
}
public static opr operator --(opr o)
{
o.a-- = o.a;
o.b-- = o.b;
return o;
}
public static opr operator -(opr o)
{
o.a = -o.a;
o.b = -o.b;
return a,b;
}
public static opr operator --(opr o)
{
o.a = --o.a;
o.b = --o.b;
return o;
}
21. A form has a button cmdCommand1, which when clicked must
display another form named frmNext. Which of the following
statements will you write in the Click event of the cmdCommand1
button? (3đ)
frmNext frmObj;
fmrObj.Show()
frmNext.Show();
show(frmNext);
15. frmNext frmObj = new frmNext();
frmObj.Show();
22. Sam is creating an application. He wants to convert a
source data from the character array, named charData, to a byte
array by using code Page 1253 format. He writes the following
code to perform this activity. (4đ)
using System.Text;
......
bype[] ByteData;
Encoding myEncoding;
myEncoding = Encoding.GetEncoding(1253);
ByteData = myEncoding.GetBytesArray(charData);
On building the application, he receives an compile time error in the
above mentioned code. How this error can be corrected?
A. Error can be corrected by modifying the given code as:
using System.Text;
......
bype[] ByteData;
Encoding myEncoding;
myEncoding = Encoding.Convert(1253);
ByteData = myEncoding.GetBytesArray(charData);
B. Error can be corrected by modifying the given code as:
using System.Text;
......
bype[] ByteData;
Encoding myEncoding;
myEncoding = new Encoding(1253);
ByteData = myEncoding.GetBytesArray(charData);
C. Error can be corrected by modifying the given code
as:
using System.Text;
......
bype[] ByteData;
Encoding myEncoding;
myEncoding = Encoding.GetEncoding(1253);
ByteData = myEncoding.GetBytes(charData);
16. D. Error can be corrected by modifying the given code as:
using System.Text;
......
bype[] ByteData;
Encoding myEncoding;
myEncoding = new Encoding(1253);
ByteData = myEncoding.GetBytes(charData);
23. Consider the following statements: (2đ)
A: Output file of a custom control is created in the <Application
Folder>Debugbin folder
B: Output file of a custim control will be a DLL file.
Which of the following option is true with regard to above
mentioned statements?
A. Both A and B True.
B. Both A and B False.
C. A True and B False.
D. A False and B True.
24. Which assembly is responsible for exposing the ActiveX
control as a .NET control? (1đ)
A. Axinterop.msacal
B. MASCAL
C. Axinterop.MSACAL
D. Axinterop.Mascal
25. You created a form named frmMainMenu. You also added a
ContexMenuStrip control named cmMenu1 to frmMainMenu. When a user
right-clicks frmMainMenu, the context menu must be displayed.
When a user selects the View option from the context menu,
another form named frmView must be displayed as the child form of
frmMainMenu. Which of the following options will help you achieve
this? (4đ)
17. A. Set the IsMdiContainer property of frmMainMenu to
True. Set the ContextMenuStrip property of
frmMainMenu to cmMenu1. Add the following code to
the event handler for the Click event of the View
menu option:
frmView frmObj = new frmView();
frmObj.MdiParent = this;
frmObj.Show();
B. Set the IsMdiContainer property of frmMainMenu to True. Set the
ContextMenuStrip property of frmView to cmMenu1. Add the following code
to the event handler for the Click event of the View menu option:
frmView frmObj = new frmView();
frmObj.MdiParent = this;
C. Set the IsMdiContainer property of frmView to True. Set the
ContextMenuStrip property of frmView to True. Add the following code to
the event handler for the Click event of the View menu option:
frmView frmObj = new frmView();
frmObj.MdiParent = this;
frmObj.Show();
D. Set the IsMdiContainer property of frmMainMenu to True. Set the
ContextMenuStrip property of frmMainMenu to True. Add the following
code to the event handler for the Click event of the View menu option:
frmView frmObj = new frmView();
frmObj.MdiParent = this;
frmObj.Show();
26. Sam is developing an application. He wants to write code to
play a wave file on the Click event of a Button control, named
btnPlay. The name of the wave file to be played is already stored
in a string variable, named MusicFile. Due to large size of the
wave file, he wants that the file should be loaded asynchronously
in the background. Which of the following options gives the
correct code to perform this activity? (3đ)
using System.Media;
.......
private void btnPlay_Click(object sender, EventArgs e)
18. {
SoundPlayer sp = new SoundPlayer();
sp.LoadAysnc(MusicFile);
sp.Play();
}
using System.Media;
.......
private void btnPlay_Click(object sender, EventArgs e)
{
SoundPlayer sp = new SoundPlayer(MusicFile);
sp.Play();
}
using System.Media;
.......
private void btnPlay_Click(object sender, EventArgs e)
{
SoundPlayer sp = SoundPlayer.LaodAsync(MusicFile);
sp.Play();
}
using System.Media;
.......
private void btnPlay_Click(object sender, EventArgs e)
{
SoundPlayer sp = new SoundPlayer();
sp.LoadAysnc(MusicFile);
sp.PlayAsync();
}
27. Which of the following method of the Process control will
stop the execution of a process for specified number of seconds?
(1đ)
A. Sleep()
B. SleepForExit()
C. WaitForExit()
D. Wait()
19. 28. John is creating an MDI application. The application
contains an MDI parent form named depDetails and an MDI child
form frmSales. Now he wants that when a user click the menuSales
menu iten on the deptDetails form than the frmSales form should
be displayed. Which of the following code option will perform the
desired operation? (3đ)
private void menuSales_Click(object sender, EventArgs
e)
{
frmSales objSales = new frmSales();
objSales.MdiParent = this;
objSales.Show();
}
private void menuSales_Click(object sender, EventArgs e)
{
frmSales objSales = new frmSales();
objSales.MdiParent = this;
frmSales.Show();
}
private void menuSales_Click(object sender, EventArgs e)
{
Form objSales = new Form(frmSales);
objSales.MdiParent = this;
objSales.Show();
}
private void menuSales_Click(object sender, EventArgs e)
{
frmSales objSales = new frmSales();
objSales.MdiParent = deptDetails;
objSales.Show();
}
29. Mary needs to write a program to divide two numbers. She
needs to ensure that the program does not terminate abruptly in
the event of any exception. Write a code that would enable Mary
to accomplish her task. (3đ)
20. using System;
class Test
{
public static void calculate(int number1, int
number2)
{
try
{
int res = number1 / number2;
Console.WriteLine(res);
}
catch(DivideByZeroException e)
{
Console.WriteLine(e.ToString());
}
}
public static void Main()
{
Test.calculate(8, 0);
Console.ReadLine();
}
}
using System;
class Test
{
public static void calculate(int number1, int number2)
{
try
{
int res = number1 / number2;
Console.WriteLine(res);
}
Throw DivideByZeroException e){}
}
public static void Main()
{
Test.calculate(8, 0);
Console.ReadLine();
}
}
21. using System;
class Test
{
public static void calculate(int number1, int number2)
{
try
{
int res = number1 / number2;
Console.WriteLine(res);
catch(DivideByZeroException e)
Console.WriteLine(e.ToString());
}
}
public static void Main()
{
Test.calculate(8, 0);
Console.ReadLine();
}
}
using System;
class Test
{
public static void calculate(int number1, int number2)
{
try
{
int res = number1 / number2;
Console.WriteLine(res);
}
catch(IndexOutOfRangeException e)
{
Console.WriteLine(e.ToString());
}
}
public static void Main()
{
Test.calculate(8, 0);
Console.ReadLine();
}
}
30. Which of the following controls you need to add to the form
to invoke the default Print dialog box? (1đ)
22. A. PageSetupDialog and PrintPreviewDialog
B. PrintDialog and PrintDocument
C. PrintDocument and PrinPreviewDialog
D. PrintDialog and PrintPreviewDialog
31. Which of the following option will convert an integer
variable, named MuCurrency, to the culture specific currency
formating? (2đ)
A. MyCurrency.ToString("C",
Thread.CurrentThead.CurrentCulture);
B. Thead.CurrentThread.CurrentUlCulture.MyCurrency.ToString("C");
C. Thread.CurrentThread.CurrentCulture.MyCurrency.ToString("C");
D. MyCurrency.ToString("C", Thread.CurrentThread.CurrentUlCulture);
32. Which of the following value of SelectionMode property of
ListBox control allows the user to select multiple items and use
the Shift, Ctrl, and arrow keys to make selections from the
ListBox control? (2đ)
A. MultipleExtended
B. MultiSimple
C. MultiExtended
D. MultiSelection
33. Ivan is creating a Windows form named form1 for an
application. He wants to add a Button control named button1 in
the form at the run time. He also wants to add a click event for
the button1, which should display a message box with the message
“Button Clicked” when the user clicks the button. He adds the
following code in the form1 class to perform this activity. (4đ)
private void Form1_Load(object sender, EventArgs e)
{
button1.Text = "Click me";
this.Controls.Add(button1);
}
public Form1()
{
InitializeComponent();
23. }
private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show("Button Clicked");
}
When Ivan runs the applications and clicks the button1, no message box
is displayed. How this error can be corrected?
A. Use Form.Controls.Add(button1); code line in place of
this.Controls.Add(button1); code line in the Form1_Load event.
B. Add the following code beneath the
InitializeComponent() line of button1.Click += new
EventHandler(button1_Click);
C. Use Message.Show() method in place of MessageBox.Show() method in the
button1_Click() event.
D. Create the instance of the Button control inside the Form1_Load method
in place of outside the Form1_Load method.
34. Sam is creating a Windows form for a GUI application. In
addition to other controls, he adds an ErrorProvider control
named errorProvider1 to the form and use the SetError method to
display error messages for various controls. In case of any
error. Now he wants that error icon of the errorProvider1 should
not blink while notifying the error for any control. Which of the
following code snippet will change the blinking property of the
error icon accordingly? (3đ)
A. errorProvider1.BlinkStyle = ErrorBlinkStyle.DoNotBlink;
B. errorProvider1.BlinkStyle =
ErrorBlinkStyle.NeverBlink;
C. errorProvider1.BlinkRate = ErrorBlinkStyle.NeverBlink;
D. errorProvider1.BlinkRate = ErrorBlinkStyle.DoNotBlink;
35. Which of the following statements correctly describes the
DragOver event of the drag-and-drop operation? (2đ)
24. A. DragOver event is triggered when a user drags an
item while the moise pointer is within the limits
of the control’s boundaries.
B. DragOver event is triggered on the completion of the drag-and-drop
operation.
C. DragOver event is triggered when a user drags an item onto the
control’s boundaries.
D. DragOver event is triggered when a user drags an item out of the
control’s boundaries.
36. A cross-platform, hardware and software independent markup
language that enables you to store data in a structured form at
by using meaningful tags that can be interpreted by any computer
system is ________ (1đ)
A. JavaScript
B. XML
C. HTML
D. DHTML
37. John has developed a function, tmpConvert(), in C# to
convert temperature from Fahreheit to Celsius. He asked to modify
this function so as to display the result to the user. Therefore,
John creates a new function, tmpConvert_New(). However, he wants
to retain the previous function, tmpConvert(), which he had
created earlier. Which attribute should John user accomplish this
task? (2đ)
A. Dllimport
B. Conditional
C. WebMethod
D. Obsolete
38. Consider the following code snippet: (4đ)
class abc
{
25. public void a(string s)
{
lock (this)
{
Console.WriteLine("start");
for (int i = 0; i < 50; i++)
{
Console.Write(s);
}
Console.WriteLine("end");
}
}
}
What does the lock statements refer to?
A. It refers to Synchronization.
B. It will generate an error.
C. It refers to Lock starvation.
D. It refers to monitor locks.
39. Which predefined attribute enables you to inform the
compiler to discard a piece of target element? (1đ)
A. WebMethod
B. Obsolete
C. Dllimport
D. Conditional
40. Which of the following options is not the valid value for
Right To Left property of the form? (2đ)
A. Yes
B. No
C. True
D. Inherit
1. You created a form containing a LinkLabel control, llConnect. When a
user clicks the LinkLabel control, a browser window should open with
26. the www.yahoo.com page. Which of the following statements can you use
to perform the above task? (2đ)
A. Process.Diagnostics.Start(“http://www.yahoo.com”)
B. System.Diagnostics.Start(“http://www.yahoo.com”)
C. System.Start(“http://www.yahoo.com”)
D. System.Diagnostics.Process.Start(“http://www.yahoo.
com”)
2. Sam is creating an application. He wants that formatting of elements in
the application should be done according to the “en-US” culture, but
the data separator, string used to separate the date information,
should be used as “-“ in spite of date separator used by “en-US” (4đ)
using System.Globalization;
using System.Threading;
....
CultureInfo AppCulture = new CultureInfo("en-US");
AppCulture.DateTimeFormat.DateSeparetor = "-";
CurrentThread.CurrentCulture = AppCulture;
On building this application he finds compile time error in the above
mentioned code. How this error can be corrected?
A. The error can be corrected by modifying the given
code as:
using System.Globalization;
using System.Threading;
....
CultureInfo AppCulture = new CultureInfo("en-US");
AppCulture.DateTimeFormat.DateSeparetor = "-";
Thread.CurrentThread.CurrentCulture = AppCulture;
B. The error can be corrected by modifying the given code as:
using System.Globalization;
using System.Threading;
....
CultureInfo AppCulture = CultureInfo.GetCulture("en-US");
AppCulture.DateTimeFormat.DateSeparetor = "-";
CurrentThread.CurrentCulture = AppCulture;
C. The error can be corrected by modifying the given code as:
using System.Globalization;
using System.Threading;
27. ....
CultureInfo AppCulture = new CultureInfo("en-US");
AppCulture.DateTimeFormat.DateSeparetor = "-";
Thread.CurrentThread.Culture = AppCulture;
D. The error can be corrected by modifying the given code as:
using System.Globalization;
using System.Threading;
....
CultureInfo AppCulture = new CultureInfo("en-US");
AppCulture.DateFormat.DateSeparetor = "-";
CurrentThread.CurrentCulture = AppCulture;
3. Which of the following statement correctly describes the CurrentCulture
property of the CultureInfo class? (2đ)
A. CurrentCultere property returns an instance of the CultureInfo class
that represents the culture for culture-specific resources.
B. CurrentCulture property returns the name of the culture in the
<Language code>-<Country/Region code> format.
C. CurrentCulture property returns the full name of the culture in the
<Language code>-<Country/Region code> format.
D. CurrentCulture property returns an instance of the
CultureInfo class that represents the culture for
the current thread.
4. Which property of the ToolTip con trol is used to set the time period
for which the moise pointer remains stationary in the tooltip region
before the tooltip appears? (1đ)
A. AutopopDelay
B. ReshowDelay
C. AutomaticDelay
D. InitialDelay
5. You added a ContextMenuStrip control named cmContext1 to a form. The
control has two options, Product Master and Salas Data Entry. How will
you ensure that the menu items of cmContext1 are displayed when a user
right-clicks the form? (4đ)
A. By setting the ContextMenuStrip property of the form to True
B. By setting the ControlBox property of the form to cmContext1
C. By setting the ContextMenuStrip property of the
form to cmContext1
D. By setting the IsMdiContainer property of the
ContextMenuStrip control to the name of the form
6. Which of the following action cannot be performed on a text by using a
dialog box created by the FontDialog class? (1đ)
28. A. Change the size of the text
B. Change the font style of the text
C. Underline the text
D. Change the color the text
7. You are creating MDI application. You want to add a menu to the MDI
parent form that holds the ame of all the opened child windows and also
allows a user to switch between the opened MDI child windows. Which of
the following option gives the correct steps to perform this activity?
(3đ)
A. 1.Create a menu named Window
2.Select the Window menu from the properties window and
the property named MDIList to True
B. 1.Create a menu named Window
2.Select the Window menu from the properties window and the property named
ActiveMDIChild to True
C. 1.Create a menu named Window
2.Select the Window menu from the properties window and the property named
MDILayout to TileVertical
D. 1.Create a menu named Window
2.Select the Window menu from the properties window and set the property
named WindowList to True
8. Sam is asigned a task to write a program that displas a list of all the
files present in a particular directory. He needs to display the name
of the file, size of that file, and the extension of that file. Write
the code that would enable Sam to accomplish his task. (3đ)
A. DirectoryInfo MydirInfo = new DirectoryInfo(@"C:myDirectory");
FileInfo FilesInDir = MydirInfo.GetFiles();
foreach (FileInfo file in MydirInfo)
{
Console.WriteLine("File Name: {0} Size: {1} bytes Extension: {2} ",
file.Name, file.Length, file.Extension);
}
Console.ReadLine();
B. DirectoryInfo MydirInfo = new DirectoryInfo(@"C:myDirectory");
FileInfo FilesInDir = MydirInfo.GetFiles();
foreach (FileInfo file in MydirInfo)
{
Console.WriteLine("File Name: {0} Size: {1} bytes Extension: {2} ",
MydirInfo.Name, MydirInfo.Length, MydirInfo.Extension);
}
Console.ReadLine();
29. C. DirectoryInfo MydirInfo = new
DirectoryInfo(@"C:myDirectory");
FileInfo FilesInDir = MydirInfo.GetFiles();
foreach (FileInfo file in FileInDir)
{
Console.WriteLine("File Name: {0} Size: {1} bytes
Extension: {2} ", file.Name, file.Length,
file.Extension);
}
Console.ReadLine();
D. DirectoryInfo MydirInfo = new DirectoryInfo(@"C:myDirectory");
FileInfo FilesInDir = FilesInDir.GetFiles();
foreach (FileInfo file in FileInDir)
{
Console.WriteLine("File Name: {0} Size: {1} bytes Extension: {2} ",
file.Name, file.Length, file.Extension);
}
Console.ReadLine();
9. Which of the following property of a Windows form is set to true to
create an MDI Parent form? (1đ)
A. ActiveMdiChild
B. MdiLayout
C. IsMDIContainer
D. MdiParent
10. Which type of project is created by selecting the Class Library
template in Microsoft Visual Studio? (2đ)
A. Class Library template creates an application with a Windows user
interface.
B. Class Library template creates a console application that can run from
the command prompt.
C. Class Library template creates a class or a
reusable component (.dell or .exe) that exposes
some functionality to be used in various projects.
D. Class Library template creates a custom control that can be added to
the user interface.
11. Ivan is writing code to display a message box on the click event
of button. The message box will display a warning message to the user
with Yes, No, Cancel button. He writes the following code to display
the message box. (4đ)
private void button1_Click(object sender, EventArgs e)
{
30. MessageBox.Show("Do You want to continue", "File Save",
MessageBoxIcon.Warning, MessageBoxButtons.YesNoCancel);
}
When Ivan run this code, compile time error has occurred. How this error can
be corrected.
Ivan should modìy the given code as:
private void button1_Click(object sender, EventArgs e)
{
MessageBox.ShowMessage("Do You want to continue",
"File Save", MessageBoxButtons.YesNoCancel, ,
MessageBoxIcon.Warning);
}
Ivan should modify the given code as:
private void button1_Click(object sender, EventArgs e)
{
MessageBox.ShowMessage("Do You want to continue", "File Save",
MessageBoxIcon.Warning, MessageBoxButtons.YesNoCancel);
}
_____________________________________________________________________________
________________________
12. John is creating a Windows form named form1 for a .NET
application. He wants to add a Label control named label1 in form1 at
run time and wants to set the text property of the label1 equals to
“Welcome User”. John also wants that label1 should be displayed in red
color. Which of the following option will correctly perform this task?
(3đ)
A. Add the following code in the form1_Load event
Label label1 = new Label();
Form1.Controls.Add(label1);
label1.Text = "Welcome User";
label1.ForeColor = Color.Red;
B. Add the following code in the form1_Load event
Label label1 = new Label();
this.AddControls(label1);
label1.Text = "Welcome User";
label1.TextColor = Color.Red;
C. Add the following code in the form1_Load event
Label label1 = new Label();
this.Controls.Add(label1);
label1.Text = "Welcome User";
label1.TextColor = Color.Red;
D. Add the following code in the form1_Load event
Label label1 = new Label();
31. this.Controls.Add(label1);
label1.Text = "Welcome User";
label1.ForeColor = Color.Red;
13. Which of the following statements correctly describes the system
modal dialog box? (2đ)
A. A system modal dialog box does not allow a user to
switch focus to another area of the application,
which has invoked the dialog box. However, user can
switch to other windows application.
B. A system modal dialog box allows a user to switch focus to another area
of the application, which has invoked the dialog box. However, the user
can not switch to other windows application.
C. A system modal dialog box allows a user to switch focus to another area
of the application, which has invoked the dialog box. User can also
switch to another Windows application.
D. A system modal dialog box takes control of the entire Windows
environment. User is not allowed to switch to, or interact with, any
other Windows application.
14. Which of the following are the features of the Windows
environment? (1đ)1.10
A.Dynamic linking
B.Event-driven
C.Command Line Interface (CLI)
A. C and B
B. A and C
C. A and B
D. A,B and C
15. Consider a scenario in which there are currently two threads, T1
and T2, running on a single processor system. Now T2 has to perform
some I/O related task. Therefore, T2 blocks T1 for some time. Which
state is thread T1 currently in? (2đ)
A. Not Runnable
B. Runnable
C. Unstarted
D. Dead
16. Consider the following class definition: (4đ)
using System;
using System.Threading;
class sleep_demo
{
public static void ChildThreadCall()
32. {
Console.WriteLine("Child thread started");
int SleepTime = 5000;
Console.WriteLine("Sleeping for {0} seconds", SleepTime /1000);
Thread.Sleep(SleepTime);
Console.WriteLine("Wakeing Up");
}
}
Choose the correct definition for Main() to execute it.
public static void Main()
{
ThreadState ChildRef = new ThreadState(ChildThreadCall);
Console.WriteLine("Main - Creating Child thread");
ChildThread.Start();
Console.WriteLine("Main - Have requested the start of child thread");
Console.ReadLine();
}
_____________________________________________________________
17. Which predifined attribute enables you to inform the compiler to
discard a piece of target element? (1đ)
A. Obsolete
B. WebMethod
C. Dllimport
D. Conditional
18. Consider the following statements: (2đ)
Statement A: Crystal Reports support two models, pull and push, to access
data from a data source.
Statement B: In the push model, the database driver directly retrieves the
data from the data source.
Which of the following is true, with respect to the above statements?
A. Both A and B are True
B. Both A and B are False
C. A is True and B is False
D. A is False and B is True
19. Which of the following holds true for encapsulation? (2đ)
A. Encapsulation is defined as the process of looking for what you want in
an object or a class.
B. Encapsulation is defined as the process of allowing access to
nonessential details.
C. Encapsulation is defined as the process of
enclosing one or more items within a physical or
logical package.
D. Encapsulation is defined as the process of viewing the relevant
information to the user.
33. 20. Which class acts as the base class for all the predefined system
exceptions? (1đ)
A. System.Exception
B. System.AppDomainUnloadedException
C. System.SystemException
D. System.ApplicationException
21. Which of the following is the correct syntax for declaring a
delegate? (1đ)
A. delegate <return type> <delegate-name> <parameter
list>
B. <return type> <delegate-name> <parameter list>
C. <return type> delegate <delegate-name> <parameter list>
D. Delegate <delegate-name> <return type> <parameter list>
22. Which is an instance constructor? (1đ)
A. An instance constructor is a class that is called whenever an instance
of that class is created.
B. An instance constructor is a method that is called
whenever and instance of a class is created.
C. An instance constructor is an event that called whenever an instance of
a class is created.
D. An instance constructor is a static method that is called whenever an
instance of a class is created.
23. Mary has written a program in which she needs to accept the
values of two integer variables, number1 and number2, from the user.
After accepting two integer values from the user, she needs to perform
some modification on these integer values as shown in the following
code snippet: (4đ)
public class Test
{
void modify(ref int a, int b)
{
int temp;
temp = a;
a = b;
b = temp;
}
static void Main(string[] args)
{
Test classobj = new Test();
classobj.modify(ref Number1, Number2);
//The value of Number1 and Number2 has already been accepted from
the user
Console.ReadLine();
34. }
}
On executing the preceding code snippet, the user enters the value of Number1
as 2 and Number2 as 4. What will be the final values stored in Number1 and
Number 2 once the execution of the preceding code snippet finishes?
A. Value of Number1 = 2
Value of Number2 = 2
B. Value of Number1 = 4
Value of Number2 = 2
C. Value of Number1 = 2
Value of Number2 = 4
D. Value of Number1 = 4
Value of Number2 = 4
24. Predict the output of the following: (4đ)
using System;
using System.IO;
class classmain
{
public static void Main()
{
int i = 0; cnt = 1;
char ch;
FileStream fs = new FileStream("C:Myfile.txt",
FileMode.OpenOrCreate, FileAccess.Read);
StreamReader sr = new StreamReader(fs);
sr.BaseStream.Seek(0, SeekOrigin.Begin);
while ((i = sr.Read()) != -1)
{
ch = Convert.ToChar(i);
if (ch == ' ' || ch == 'n' || ch == 't')
cnt++;
}
Console.Write(cnt);
Console.Read();
}
}
A. It will count the number of pages in a file.
B. It will count the number of words in a file.
C. It will count the number of characters in a file.
D. It will count the number of lines in a file.
25. John has to write a program in which he wants to all the
variables of a class to be accessible only within the functions of that
35. class. Which of the following access specifier should John use to
accomplish this task? (2đ)
A. Protected
B. Internal
C. Public
D. Private
26. How may bytes are requited to store a variable of type char? (1đ)
A. 4
B. 3
C. 2
D. 1
27. Henry wants to develop a code to calculate the sum of two
numbers. These numbers should be accepted from the user. Identify the
correct code that would enable Henry to accomplish his task (3đ)
class Test
{
public void Calculate()
{
Console.WriteLine("Enter first number: ");
int num1 = Console.ReadLine();
Console.WriteLine("Enter second number: ");
int num2 = Console.ReadLine();
int result = (num1 + num2);
Console.WriteLine(result);
}
public static void Main(string[] args)
{
Test obj = new Test();
obj.Calculate();
}
}
____________________________________________
28. David Smith is a technical support in an international call
center. David is working on software, which tells him about the ratings
on his calls given by the customer. The software gives the following
messages, if the customer rating is in: (2đ)
Range 1-4: The customer is overall dissatisfied with your support.
Range 5-7: The customer is some what satisfied with your work.
Range 8-9: The customer is very satisfied and happy with your work.
Identify the programming construct implemented in the preceding software.
A. do while loop construct
B. while loop construct
C. switch case construct
D. nested if else construct
36. 29. Which data type can be used for a varuable that stores the grade
of a student in a particular exam, where the grades can be A, B or C?
(1đ)
A. Float
B. Char[]
C. Char
D. Int
30. Which of the following option of the gacutil command is used to
register the assembly to the GAC? (1đ)
10.6 .net 2 đáp án /I
A. /l
B. /u
C. /f
D. /r
31. You are configuring an application by using the application
configuration file. In this process you want to enable the concurrent
garbage collection by the CLR. Which of the following code snippet will
correctly specify the required settings? (3đ)
A. <configuration>
<runtime>
<gcConcurrent enabed=”true”/>
</runtime>
</configuration>
B. <configuration>
<startup>
<gcConcurrent enabed=”true”/>
</startup>
</configuration>
32. You need to create a database during installation. Which editor
would you use? (2đ)
A. Custom Actions Editor
B. Launch Conditions Editor
C. File Types Editor
D. User Interface Editor