0% found this document useful (0 votes)
18 views15 pages

Quiz C++

The document contains a series of multiple-choice questions and answers related to programming concepts, languages, and data types, primarily focusing on C, Java, and JavaScript. It covers topics such as UML designations, exception handling, data types, operators, and memory allocation. Each question is followed by the correct answer and a brief explanation.

Uploaded by

techytanzo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views15 pages

Quiz C++

The document contains a series of multiple-choice questions and answers related to programming concepts, languages, and data types, primarily focusing on C, Java, and JavaScript. It covers topics such as UML designations, exception handling, data types, operators, and memory allocation. Each question is followed by the correct answer and a brief explanation.

Uploaded by

techytanzo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 15

1.

The UML designation for a public class member is


(1) the symbol @
(2) the symbol #
(3) the minus symbol (-)
(4) the plus symbol (+)
(5) the word public

Ans1:(4)

2. A……………is an acyclic diagraph, which has only node with in-degree


0, and other nodes have indegree 1.

(1) Dis-joint tree


(2) Direction oriented tree
(3) directed tree
(4) Diagonalised tree
(5) Undirected tree

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

Q4. In the language C, a preprocessor is a program:


(a) That processes its input data to produce output that is used as input to another
program
(b) That is nothing but a loader
(c) That links various source files
(d) All of the mentioned
(e) None of the mentioned

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

Ans: Option (a)

Q.6. How are multi-lines comments written in PHP?

(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.

Q7. Which of the following handles the Exception in JavaScript?

(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)

Q9. Which of these selection statements test only for equality?


(a) if
(b) switch
(c) if & switch
(d) for
(e) None of the mentioned

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.

Q13. The smallest individual units in C language are known as C


tokens. Which of the following is an C token?
(a) register
(b) Operators
(c) Identifiers
(d) String
(e) all of the above

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

Q14. Which of the following are unary operators?


(a) sizeof
(b) –
(c) ++
(d) !(logical not)
(e) all of the above

Ans.(e)

Sol.The unary operators operate on a single operand.

Q15. Size of an array can be evaluated by: int a[10];


(a) sizeof(a);
(b) sizeof(*a);
(c) sizeof(a[10]);
(d) 10 * sizeof(a);
(e) none of the above

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.

Q17. What is the meant by ‘a’ in the following operation?


fp = fopen(“Random.txt”, “a”);
(a) Attach
(b) Append
(c) Apprehend
(d) Add
(e) none of the above

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

Q18. Preprocessor feature that supply line numbers and filenames to


compiler is called?
(a) Selective inclusion
(b) Macro substitution
(c) Concatenation
(d) Line control
(e) none of the above

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

Q19. Which of these have highest precedence?


(a) ( )
(b) ++
(c) --
(d) *
(e) >>

Ans.(a)
Sol.Order of precedence is: (a), (b), (c), (d), (e)

Q20. Which of the following can be operands of arithmetic


operators?
(a) Numeric
(b) Boolean
(c) Characters
(d) Both Numeric & Characters
(e) All of the above

Ans.(d)Sol.The operand of arithmetic operators can be any of numeric or


character type, But not boolean

Q21. Which of these occupy first 0 to 127 in Unicode character set


used for characters in Java?
(a) ASCII
(b) ISO-LATIN-1
(c) None of the mentioned
(d) ASCII and ISO-LATIN1
(e) EBCDIC

Ans.(d)Sol.First 0 to 127 character set in Unicode are same as those of ISO-


LATIN-1 and ASCII.

Q22. Which of the following are themselves a collection of different


data types?
(a) string
(b) struct
(c) array
(d) char
(e) enum

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.

Q24. _______is a scripting language, running on the server, which can


be used to create web pages written in HTML.
(a) PHP (Hypertext Pre-Processor)
(b) Javascript
(c) Android
(d) Adobe
(e) None of the above

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).

Q25. Which is a valid keyword in java?


(a) interface
(b) string
(c) Float
(d) unsigned
(e) all of the above

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.(a)Sol.java.lang bundles the fundamental classes

Q27. _____general purpose programming language, though it is best


known for its use in web programming, and _____ serves as a
framework for the Ruby Language.
(a) Java,IDE
(b) C#,C++
(c) Javascript,Java
(d) Ruby,Rails
(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.

Q29. What is use of wildcards?


(a) It is used in cases when type being operated upon is not known.
(b) It is used to make code more readable.
(c) It is used to access members of super class.
(d) It is used for type argument of generic method
(e) all of the above

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.

Q30. Who is the Father of 'C' programming language_________.


(a) Dennis Ritchie
(b) Prof Jhon Kemeny
(c) Thomas Kurtz
(d) Bill Gates
(e) None of these

Ans.(a)
Sol. Dennis MacAlistair Ritchie was an American computer scientist. He
created the C programming language and, with long-time colleague Ken
Thompson.

Q31. JavaScript was developed by __________ to run inside of web


pages.
(a) Microsoft
(b) Sun
(C) Oracle
(d) Netscape
(e) None of these

Ans.(d)Sol. JavaScript ("JS" for short) is a full-fledged dynamic programming


language that, when applied to an HTML document, can provide dynamic
interactivity on websites. It was invented by Brendan Eich, co-founder of the
Mozilla project then working at NETSCAPE.

Q32. What is the range of data type short in Java?


(a) -128 to 127
(b) -32768 to 32767
(c) -2147483648 to 2147483647
(d) -32768 to 2147483647
(e) None of the mentioned

Ans.(B) Short occupies 16 bits in memory. Its range is from -32768 to 32767.

Q33. What is the range of data type byte in Java?


(a) -128 to 127
(b) -32768 to 32767
(c) -2147483648 to 2147483647
(e) -32768 to 2147483647
(d) None of the mentioned

Ans.(A):Byte occupies 8 bits in memory. Its range is from -128 to 127.

Q34. Which one of these literals can be contained in a data type


float variable?
(a) 1.7e-308
(b) 3.4e-038
(c) 1.7e+308
(d) 3.4e-050
(e) All of the above

Ans.(B) Range of data type float is 3.4e-038 to 3.4e+308.

Q35. An expression involving byte, int, and literal numbers is


promoted to Which one of these?
(a) int
(b) long
(c) byte
(d) float
(e)double
Ans.(A)Sol. An expression involving bytes, ints, shorts, literal numbers, the entire
expression is promoted to int before any calculation is done.

Q36. Which one of these operators is used to allocate memory to


array variable in Java?
(a) malloc
(b) alloc
(c) new
(d) new malloc
(e) create

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.

Q37. Which one of these is an incorrect Statement?


(a) It is necessary to use new operator to initialize an array.
(b) Array can be initialized using comma separated expressions surrounded
by curly braces.
(c) Array can be initialized when they are declared.
(d) Array stores a fixed-size sequential collection of elements of the same
type
(e) All of the above

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};

Q38. What is the numerical range of a char in Java?


(a) -128 to 127
(b) 0 to 256
(c) 0 to 32767
(d) 0 to 65535
(e) None of the above

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

Q40. Which one of these values can a Boolean variable contain?


(a) True & False
(b) 0 & 1
(c) Any integer value
(d) true
(e)All of the above

Ans.(A)
Sol. Boolean variable can contain only one of two possible values, true and false

Q41. Which one of these occupy first 0 to 127 in Unicode character


set used for characters in Java?
(a) ASCII
(b) ISO-LATIN-1
(c) None of the mentioned
(d) ASCII and ISO-LATIN1
(e)EBCDIC

Ans.(D)Sol. First 0 to 127 character set in Unicode are same as those of ISO-LAIN-1
and ASCII.

Q42. Which of the following can be operands of arithmetic


operators?
(a) Numeric
(b) Boolean
(c) Characters
(d) Both Numeric & Characters
(e) All of the above

S11. Ans.(D)
Sol. The operand of arithmetic operators can be any of numeric or character type, But
not boolean.

Q43. Which one of these statements are incorrect?


(a) Assignment operators are more efficiently implemented by Java run-time
system than their equivalent long forms.
(b) Assignment operators run faster than their equivalent long forms.
(c) Assignment operators can be used only with numeric and character data
type.
(d) += adds right operand to the left operand and assign the result to left
operand.
(e) None of the above
S12. Ans.(E)

Sol. All options are characteristic of assignment operator.

Q44. Which one of these is not a bitwise operator?


(a) &
(b) &=
(c) |=
(d) <=
(e) All are bitwise operators.

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.

Q45. Which one of these have highest precedence?


(a) ()
(b) ++
(c) --
(d) *
(e)>>

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.

Q.47. Which of the following data structure is linear data structure?


Array
Tree
Graph
Both (b) & (c)
None of the above
Ans 1)

Q. Static import form class and declaration in JAVA?

48.Which of the following is not OOPS concept in Java?


a)Inheritance
b)Encapsulation
c)Polymorphism
d)Compilation

Answer:d
Explanation: There are 4 OOPS concepts in Java. Inheritance, Encapsulation, Polymorphism
and Abstraction.

49. When does method overloading is determined?


a)At run time
b)At compile time
c)At coding time
d)At execution time
View Answer
Answer:b
Explanation: Overloading is determined at compile time. Hence, it is also known as compile time
polymorphism.

50. When Overloading does not occur?


a) More than one method with same name but different method signature and different number
or type of parameters
b) More than one method with same name, same signature but different number of signature
c) More than one method with same name, same signature, same number of parameters but
different type
d) More than one method with same name, same number of parameters and type but different
signature

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.

51. Which of these keywords are used to define an abstract class?


a) abst
b) abstract
c) Abstract
d) abstract class
View Answer
Answer: b
Explanation: None.

52.Which of these is not abstract?


a) Thread
b) AbstractList
c) List
d) None of the Mentioned
View Answer
Answer: a
Explanation: Thread is not an abstract class.

53. Which of these packages contains abstract keyword?


a) java.lang
b) java.util
c) java.io
d) java.system
View Answer
Answer: a
Explanation: None.

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.

56. Method overriding is combination of inheritance and polymorphism?


a) True
b) false
View Answer
Answer: a
Explanation: In order for method overriding, method with same signation in both superclass and
subclass is required with same signature. That satisfies both concepts inheritance and
polymorphism.

You might also like