Font size
WorksheetsOOP C#
Total questions: 121
Worksheet time: 1hrs 19mins
What will be printed to the console when this code is executed?
<(`^´)>
true
expr
¯\_(ツ)_/¯
What’s wrong with this code?
There are no switch statements in C#
There are not enough cases
There are no break statements
num should be type string
What possible values can a bool variable take?
on and off
right and wrong
"true" and "false"
true and false
What will happen when this code is executed?
"x is greater than zero" is printed
"x is equal to zero" is printed
"x is less than zero" is printed
There will be an error
What will be printed to the console when this code is executed?
x is less than zero
Nothing will be printed
x is greater than zero
x is equal to zero
Which of these is not one of the primary principles of object-oriented programming?
Encapsulation
Polymorphism
Generalisation
Inheritance
Why are encapsulation and abstraction important?
They allow you to reuse code
Change implementation details without affecting other code that uses the class
Create other classes that use the same properties and methods
Reduce problems into more manageable parts
How do properties enable a class to meet the goals of encapsulation?
They provide a public way to access a private field
They make all data private
They make all data public
They represent data associated with a class
What type of inheritance does C# support?
Single and Multiple Inheritance
Multiple Inheritance
Single Inheritance only
What is polymorphism?
Where information is hidden
Where information is shared with other classes
The capability of one type to be used like another type
A new class that inherits properties and methods from its parent.
What are the types of control flow statements available in C#?
Sequence, Selection & Iteration
Iteration, Sequence & Jump
Jump, Selection & Sequence
Selection, Iteration & Jump
What is the difference between the while and do statements?
While is bottom-tested do is top-tested
While is top-tested, do is bottom-tested
Do loops may never be executed
While statements will always be executed at least once
How many default cases can a switch statement have?
One
Two
At least one
As many as you need
Which operator is used to concatenate strings?
+
-
/
%
What does the StringBuilder class do?
Makes all strings immutable
Creates temporary strings
Creates mutable strings
Manipulates immutable strings
Procedure oriented Programming is also known as modular programming.
True
False
Which of the following is a limitation of procedure oriented programming paradigm.
Data/variables can be declared as global.
Data/variables can be declared as Local.
Main Program can be divided into sub programs.
Allow User defined functions.
OOP allows decomposition of a problem into number of entities called
(a)
Which of the following is a part of Java Development Kit?
Java runtime environment
Java Development kit
Java Virtual Machine
All of them
How many Bytes are reserved for "Char" data type in JAVA?
1 Byte
2 Bytes
2 Bits
14 Bits
A Java file with extension .class contains
Java source code
HTML Tags
Java Bytecodes
A program file written in java programming language
Which of the following is not a primitive data type of JAVA?
int
char
String
float
Java is a platform independent programming language because
It is written almost similar to English language
Java compiler translates the source code directly to the machine level language.
It follows the concept of “write once and compile everywhere”.
It compiles to an intermediate code targeting a virtual machine, which can be interpreted by an interpreter for a given OS.
So far the declaration of main() method is concerned, which of the following specification is not valid?
void
public
private
static
Scanner inp= new Scanner(System.in);
What is System.in in this declaration?
Any file storing data
Reference to standard input device, that is, keyboard
Reference to a scanner as an input device
It is a mouse as an input device
Which of the following features are not common in both java and c++?
The class declaration
The access modifiers
The Encapsulation of data and methods
multiple inheritance from class
What is the output of following program?
class incr
{
public static void main(String args[])
{
int i=3;
System.out.println( ++i * 5);
}
}
(a)
Which of the following can not be used as correct variable name(identifier) in JAVA?
malloc
final
calloc
string
A template used to create objects...
Subroutine
Function
Class
An instance of a class...
Object
Function
Variable
In C#, what are these lines of code called?
Output
Comments
Inputs
Commands
What is the outcome of these lines of code?
The text "Let's get started" is printed
No text is printed until the user types into the console
The text "Press Enter to begin..." and the computer waits for the user to press Enter
The texts "Press Enter to begin..." and "Let's get started!" are printed
What is the outcome of this line of code?
The computer waits for the user to type something
The computer outputs whatever the user last entered
The computer outputs "Console.ReadLine()"
The computer copies all of the text in the console
What is the outcome of this line of code?
The text WriteLine is printed
The text Console.WriteLine("Open Sesame!") is printed
The text "Open Sesame" is printed
No text is printed
What is NOT a good reason to use comments in your code?
Ignore a line of code to see how a program will run without it
Provide context why something is written the way it is
Help other people reading the code to understand it faster
To instruct a computer to execute a block of code
terminates the execution of the method and gives back the control to the calling method
Return
Parameter
Procedure
Property
A function that does not return a value as a return type
If
Void
String
Int
values that have one of only two values: either true or false
Int
string
double
boolean
specify what kind of data a valid C# variable can hold
data holder
datatype
data
data link
An ______ is created from a class. We have already created the class named Car, so now we can use this to create objects.
To create an ______ of Car, specify the class name, followed by the object name, and use the keyword new
(a)
Choose the right form
it is one to inherit possible fields and methods from class to another
is it possible to inherit and methods fields from class one to another
it is one possible to fields another and to inherit methods from class
it is possible to inherit fields and methods from one class to another
Data (a) is the process of hiding certain details and showing only essential information to the user
things that happen such as a user action with the mouse or keyboard
Click
Event
Action
Property
used to iterate over the elements of the collection. A control structure that processes all of the elements in an array
for loop
while loop
for each loop
do while loop
Choose the right form
objects classes and the two main aspects are of programming object-oriented
classes and objects are the two main aspects of object-oriented programming
classes are objects and the two main aspects of programming object-oriented
main classes and objects are two aspects of the object-oriented programming
means that you can create a base class, such as a cube, and then derive another class, such as a Box, that gets all of the properties of a Cube, but it is extended to have additional properties, such as a lid
Abstraction
Exception
inheritance
Nested Loop
required to extend or modify the abstract or virtual implementation of an inherited method, property, indexer, or event
overall
override
inherit
abstract
Fill the gaps.
___Declaring an integer
and printing it___
int x = 42;
LblOutput.Text=Convert.ToString(x);
//.........//
/*............*/
<----...................----->
?-------------?
Which operator is used to determine the remainder?
*
%
+
-
What is the alternative for x = x + 5?
x += 5;
x -= 4;
x = y + 5;
x=+5
Choose the right form
the meaning of Encapsulation, is to make sure that "sensitive" data is hidden from users
Encapsulation meaning the of , is sure to make that data "sensitive" is hidden from users
the meaning of "sensitive" Encapsulation, is sure to make data that is hidden from users
from users to Encapsulation the meaning data of , is make sure that "sensitive" is hidden
A (a) is like a combination of a variable and a method, and it has two methods: a get and a set method
used to convert a string to a numeric format
TryParse
Convert.ToInt32
Convert.ToDouble
String.Format
Most modern programming environments allow you to create the program, edit it and run it from one application
Visual Studio Code
IDE
C#
Windows Form
placed on the form to create a GUI (graphical user interface). Some commonly used are buttons, text boxes, labels, scroll bars and checkboxes
Controls
Tools
Graphical
Composition is also known as
Modularity
Encapsulation
Aggregation
Instantiation
Choose the FALSE statement about abstract class
It is a superclass with generic behaviour
Definition of abstract method is implemented in subclass
Subclasses must implement all the abstract methods in the superclass
Abstract class must have more than one abstract method
Which are the key concepts of imperative programming?
I. Variables
II. Commands
III. Procedures
IV. Data abstraction
I, II
I, III
I, II, III
I, II, III, IV
The real-world processes that inspect and update these variables define the key concept __________ in imperative programming.
Variables
Commands
Procedures
Data abstraction
Overloading operator in object oriented programming is ____________
Using same operator for different effect based on operands data type
Replacing the meaning of an operator with a user defined operator
Using the operator for more than one in a statement
Operator that uses prefix notation
C programming supports ______________ variables.
I. global
II. local
III. heap
I and II
I and III
II and III
I, II and III
Which of the following is NOT a primitive data type?
Enumeration types
Boolean types
Integer types
Floating point types
_______________ is a key concept, enabling an object of a subclass to be treated like an object of its superclass.
Classes and subclasses
Data abstraction
Inclusion polymorphism
Parametric polymorphism
Which of the following is NOT a valid data type in C?
float
double
char
str
The format identifier ‘%i’ is used for _____ data type?
char
int
float
boolean
What is a pointer in C language?
A variable used to store address of other variable
A keyword to declare variables
A variable used to store address of an instruction
A variable used to store address of a structure
Composite values in JAVA are _______________
dictionaries
objects
tuples
lists
A/ An ________________is a blueprint that defines the variables and the methods common to all objects of a certain kind.
class
object
abstraction
encapsulation
Which modifier allows subclass access to the superclass from different packages?
private
protected
public
default
What is the similarity between a structure, union, and enumeration?
All of them let you define new values
All of them let you define new pointer
All of them let you define new structures
All of them let you define new data types
Which Feature of OOP illustrated the code reusability?
Polymorphism
Abstraction
Encapsulation
Inheritance
Choose the attributes of Class: time
Hours
second
get Hour
Print Time
Choose the behaviour of Class: time
Hour
Second
PrintTime
getHour
As a Vehicle user, we know how to use it but its internal working are not known. In OOPs Concept, this principle is known as
Encapsulation
Inheritance
Abstraction
Polymorphism
Advantages of OOPs
Code Reusability
Modular Programming
Easy Maintenance
Security
Apple is a derivation of the Fruit class?
True
False
“Write once and use it multiple time” can be achieved by
(A) redundancy
(B) reusability
(C) modification
(D) composition
Insulation of the data from direct access by the program is called as
(A) Data hiding
(B) Encapsulation
(C) Polymorphism
(D) Abstraction
The ability of a message or function to be displayed in more than one form is ____
Data Abstraction
Inheritance
encapsulation
Polymorphism
The Object Oriented Programing has been developed to overcome the drawbacks of _____ programming.
Procedural
Modular
Functional
both a and b
Basically an object is created from a
Behaviour
Class
Characteristics
Module
The technique of building new classes (derived class) from an existing class (Base class )is called _____
Parent class
Data hiding
Inheritance
Polymorphism
The mechanism by which the data and functions are bound together into a single unit is known as
Class
Object
ENCAPSULATION
POLYMORPHISM
The term is used to describe a programming approach based on classes and objects is
(A) OOP
(B) POP
(C) ADT
(D) SOP
Which of the following is a user defined data type?
int
float
class
object
A single object can also be referred to as an...
Object
Singular Object
Instance
Singular
You can instantiate an object more than once?
True
False
