Quiz C++
Quiz C++
Ans1:(4)
Ans: 2.(3) A directed tree is an acyclic digraph, which has only one node with indegree
0, and others nodes have indegree 1.
3.Which one of the following languages is the system programming language derived
from Pascal and intended for the defence application?
(1)C-language
(2)C++ language
(3)FORTRAN
(4)Ada
(5)None of the above
Ans:Ada
Ans: Ans:(a)
Sol. A preprocessor is a program that processes its input data to produce output that is
used as input to another program.
Q5. Predict the output of given C Program:
#include <stdio.h>
int main()
{
float c = 5.0;
printf ("Temperature in Fahrenheit is %.2f", (9.0/5.0)*c + 32);
return 0;
}
(a) Temperature in Fahrenheit is 41.00
(b) Temperature in Fahrenheit is 37.00
(c) Temperature in Fahrenheit is 0.00
(d) No Output
(e) Compiler Error
(a) */ */
(b) /* */
(c) //
(d) @/ @/
(e) None of the above
Ans.(b)
Sol. Multi-line comments in PHP are written for illustrating the piece of code or writing
any description to better understand the program.
(a) Try...catch
(b) Throw statement
(c) For statement
(d) Error..statement
(e) none of these
Ans.(a)
Sol. An exception are run-time errors that occur at the time of execution of
a program. The exceptions are handled by the try..catch statement.
Q8. In C++, which of the following belongs to the set of character types?
(a) char
(b) wchar_t
(c) only a
(d) Both wchar_t and char
(e) Both char and wchar
Ans.(d)
S4. Ans.(b)
Sol. Unlike if-then and if-then-else statements, the switch statement can have a number of
possible execution paths. A switch works with the byte, short, char, and int primitive data types.
Q10.What is a flowchart?
(a)It represents process
(b)It represents algorithm.
(c)It represents process or algorithm.
(d)It represents mathematical subtraction.
(e)None of these
Ans.(c)
Sol. Flowchart is a man-made diagram on paper, to represent
algorithm and process both.
Q11._____is the the scripting language of the World Wide Web and is
built right into all major web browsers including Internet
Explorer, FireFox and Safari.
(a) HTML
(b) Flash player
(c) Javascript
(d) Adobe
(e) Python
Ans.(c)
Sol. JavaScript – not to be confused with Java – is another one of the world’s most
popular and powerful programming languages, and is used to spice up web pages by
making them interactive. For example, JavaScript can be used to add effects to web
pages, display pop-up messages or to create games with basic functionality.
Q12.In 2014, Apple decided to invent their own programming
language.What is the programming language called?
(a) Cyanogen
(b) Ruby
(c) Swift
(d) Oxygen
(e) None of these
Ans.(c)
Sol. Swift – a new programming language for iOS and OS X developers to create
their Apps.
S1.Ans.(e)
Sol.C tokens can be classified as follows: Keywords(float, enum, auto, float);
Identifiers(There are certain rules that should be followed while naming
identifiers), Constants; Strings; Special Symbols({}); Operators
Ans.(e)
S3.Ans.(a)
Sol.To determine the size of your array in bytes, you can use the sizeof
operator: int a[10]; int n = sizeof(a); On some computer, ints are 4 bytes
long, so n is 40. To determine the number of elements in the array, we can
divide the total size of the array by the size of the array element.
Q16. Size of a union is determined by size of the?
(a) First member in the union
(b) Last member in the union
(c) Biggest member in the union
(d) Sum of the sizes of all members
(e) All of the above
S4.Ans.(c)
Sol.A union is a special data type available in C that allows storing different
data types in the same memory location. You can define a union with many
members, but only one member can contain a value at any given time. In a
union, at most one of the data members can be active at any time, that is,
the value of at most one of the data members can be stored in a union at any
time.
Ans.(b)
Sol.When you open with "a" mode, the write position will always be at the
end of the file. opening the file with 'a' guarantees that all your following
writes will be appended atomically to the end of the file
Ans.(d)
Sol.The C preprocessor is a macro processor that is used automatically by
the C compiler to transform your program before actual compilation. It is
called a macro processor because it allows you to define macros, which are
brief abbreviations for longer constructs
Ans.(a)
Sol.Order of precedence is: (a), (b), (c), (d), (e)
Ans.(b)Sol.Arrays allow defining type of variables that can hold several data
items of the same kind. Similarly, structure is another user defined data type
available in C that allows combining data items of different kinds. Structures
are used to represent a record.
Q23. ______is the a relatively new programming language designed
by Microsoft for a wide range of enterprise applications that run on
the .NET Framework.
(a) RUBY on RAILS
(b) PYTHON
(c) JAVA
(d) C#(pronounced C-sharp)
(e) None of these
Ans.(d)
Sol. An evolution of C and C++, the C# language is simple, modern, type
safe and object oriented.
Ans.(a)
Sol. Created by Danish-Canadian programmer Rasmus Lerdorf in 1994, PHP
was never actually intended to be a new programming language. Instead, it
was created to be a set of tools to help Rasmus maintain his Personal Home
Page (PHP).
Ans.(a)
Sol. In the Java programming language, a keyword is one of 50 reserved
words that have a predefined meaning in the language.
Q26. Which of the following package stores all the standard java
classes?
(a) java.lang
(b) java.io
(c) util
(d) java.packages
(e) none of the above
Ans.(d)
Sol. Ruby on Rails has many positive qualities including rapid development,
you don’t need as much code, and there are a wide variety of 3rd party
libraries available.
Q28. Which of these keywords are used for the block to be examined
for exceptions?
(a) try
(b) catch
(c) throw
(d) all of the above
(e) check
Ans.(d)
Sol. An exception occurs in try block then the control of execution is passed
to the catch block from try block. The exception is caught up by the
corresponding catch block.
Ans.(a)
Sol. In generic code, the question mark (?), called the wildcard, represents
an unknown type. The wildcard can be used in a variety of situations: as the
type of a parameter, field, or local variable; sometimes as a return type.
Ans.(a)
Sol. Dennis MacAlistair Ritchie was an American computer scientist. He
created the C programming language and, with long-time colleague Ken
Thompson.
Ans.(B) Short occupies 16 bits in memory. Its range is from -32768 to 32767.
Ans(C) Operator new allocates block of memory specified by the size of array, and gives
the reference of memory allocated to the array variable.
Ans.(A)Sol. Array can be initialized using both new and comma separated expressions
surrounded by curly braces example : int arr[5] = new int[5]; and int arr[] = { 0, 1, 2, 3, 4};
Ans.(D)
Sol. Char occupies 16-bit in memory, so it supports 2^16 i:e from 0 to 65535.
Q39. Which one of these coding types is used for data type
characters in Java?
(a) A1SCII
(b) ISO-LATIN-1
(c) UNICODE
(d)EBCDIC
(e) None of the above
Ans.(C)
Sol. Unicode defines fully international character set that can represent all the characters
found in all human languages. Its range is from 0 to 65536
Ans.(A)
Sol. Boolean variable can contain only one of two possible values, true and false
Ans.(D)Sol. First 0 to 127 character set in Unicode are same as those of ISO-LAIN-1
and ASCII.
S11. Ans.(D)
Sol. The operand of arithmetic operators can be any of numeric or character type, But
not boolean.
S13. Ans.(D)
Sol. In digital computer programming, a bitwise operation operates on one or more bit
patterns or binary numerals at the level of their individual bits. It is a fast, simple action
directly supported by the processor, and is used to manipulate values for comparisons
and calculations.
Ans.(A)
Sol. Order of precedence is a, b, c, d, e
Q46. Which one of these selection statements test only for equality?
(a) if
(b) switch
(c) if & switch
(d)for
(e) None of the mentioned
Ans.(B)
Sol. switch statements checks for equality between the controlling variable and its
constant cases.
Answer:d
Explanation: There are 4 OOPS concepts in Java. Inheritance, Encapsulation, Polymorphism
and Abstraction.
Correct Answer: d
Explanation: Overloading occurs when more than one method with same name but different
constructor and also when same signature but different number of parameters and/or parameter
type.
54. Which of these keyword can be used in subclass to call the constructor of
superclass?
a) super
b) this
c) extent
d) extends
View Answer
Answer: a
Explanation: None.
55. Which concept of Java is achieved by combining methods and attribute into a class?
a) Encapsulation
b) Inheritance
c) Polymorphism
d) Abstration
View Answer
Answer: a
Explanation: Encapsulation is implemented by combining methods and attribute into a class. The
class acts like a container of encapsulating properties.