stud
bud
Sign up
Log in
Home
Library
Explore
SAT
More
oop formatives compiled wow Flashcards | StudBud
Explore
/
oop formatives compiled wow
oop formatives compiled wow
100 terms
·
StudBud Administration
·
12 plays
Imported from external platform
Flashcards
100 cards
F
Practice quiz
P
Host live
L
Questions
100
Answers
1
Choose a correct version of Java Documentation Comment?
/**comments**/
/**comments*/
/* comments**/
/* Comments*/
2
What is the design pattern followed by Iterator?
None
Observer design pattern
Iterator design pattern
Factory design pattern
3
What is an abstract class?
An abstract class is class which cannot be instantiated.
abstract class is another name for "base class."
An abstract class is any parent class with more than one child class.
An abstract class is one without any child classes.
4
Escape character for new line.
\\
\n
\t
5
What will be the output of the following program?
Result = 50400
Result = 360
Result = 604800
Throws ArrayIndexOutOfBoundsException
6
Compare the following program
CrossCheck2 does not compile, but CorssCheck1 will compile.
Both CrossCheck1 and CrossCheck2 compile, but they produce different output
Both CrossCheck1 and CrossCheck2 produce same output.
CrossCheck1 does not compile, but CrossCheck2 will compile.
7
Scanner class is found on java.io package.
True
False
8
There are no direct implementation of the Collection interface?
False
True
9
Which of the following method you need to override for using an object as key in a HashMap?
hashKey()
hashValue()
None
hashCode()
10
image:
GUI builder
version control support
XML
11
Which of the following is not an advantage to using inheritance?
One big superclass can be used instead of many little classes.
Enhancements to a base class will automatically be applied to derived class
Code that is shared between classes needs to be written only once.
Similar classes can be made to behave consistently.
12
A _____ is a sequence of data.
collection
string
stream
13
write (char[] c) is a method of the FileWriter class that is used to write char array into FileWriter.
False
True
14
What is the result of -7%2
-2
2
-1
1
15
What will be the output of the following program?
0 1 2 4 7 11 16 22 30 37
0 1 2 1 2 3 4 2 3 4
Compilation Error
Throws ArrayIndexOutOfBoundsException
16
image:
enterprise edition
micro edition
standard edition
17
The while loop executes a given statement or a block of statements for a definite number of times.
False
True
18
What is an exception?
Problem in syntax
Problem arising during runtime
Problem in IDE
Problem arising during compile time
19
The foreach loop is for traversing items in a collection
False
True
20
What are the valid White Spaces available in Java language?
tab
enter
space
all of the above
21
It is not required for the caller method to catch or re-throw the checked exception.
True
False
22
Scanner class is found on java.util package.
True
False
23
statements associated with ___ is executed if the value of the switch variable does not match any of the case constants.
else
default
last option
24
Which of the following classes fail to compile?
All classes compile
X
Y
Y Z
25
All are valid codes in printing error message in the console, except one.
System.err.println("Hello");
System.err.print="Hello";
System.err.print("Hello");
System.err.printf("%s","Hello");
26
What will be the output of the program?
compilation fails
bar
foo done
bar done
27
static Method: used in defining a class method
True
False
28
a method a method that is accessible from all classes.
protected method
private method
public method
29
To catch the exceptions ___________________
A string have to be created to store the exception
A variable should be created to catch the exception
An object must be created to catch the exception
An array should be created to catch all the exceptions
30
Consider the following codes:
1
4
2
3
31
Which List class is synchronized?
LinkedList
Vector
ArrayList
32
When does method overloading is determined?
At compile time
At coding time
At run time
At execution time
33
Which concept will result in derived class with more features (consider maximum 3 classes)?
Multiple inheritance
Single inheritance
Multilevel inheritance
Hierarchical inheritance
34
static Variable used in defining a class variable
True
False
35
short has a width of 4 bytes
False
True
36
What method of an Exception object returns a message string?
traceMessage()
printMessage()
getMessage()
getError()
37
Which language doesn't support single level inheritance?
Kotlin
Java
All languages support it
C++
38
How can you make the private members inheritable?
It can be done both by making the visibility mode public or protected
By making their visibility mode as protected only
By making their visibility mode as public only
By making their visibility mode as private in derived class
39
is normally compiled to produce the bytecode(.class)file which is normally interpreted by the Java virtual machine (JVM)
java class file
java source code
java program
java netbeans
40
It is a class used to get user input.
in
input
scanner
scan
41
Which of these interface declares core method that all collections will have?
Comparator
EventListner
set
Collection
42
Access (Getter) – a method that is used to access or retrieve data.
True
False
43
Which of the following is not true for a generic collection?
None
Generic collection is typesafe and checked at compile time.
Generic collection is not mutable.
Generic collection doesn't require typecasting.
44
Custom Methods – implement the business rules for which the application is being developed
False
True
45
The private members of the base class are visible in derived class but are not accessible directly.
True
False
46
If a base class is inherited in protected access mode then which among the following is true?
Private, Protected and Public all members of base, become private members
Only private members of base, become private of derived class
Public & Protected members of base class becomes protected members
Only protected members become protected members of derived class
47
A method must do either of two things with a checked exception. What are those two things?
b
d
c
a
48
situation:
Rodent[] array = new Rat[10];
Rodent[] array = new Rodent[10];
Rat[] array = new Rat[10];
Rodent[10] array;
49
Which of the following statements is true?
c
a
d
b
50
What type of variables can we use with the java.util.Collections Class?
neither
primitive variables
reference variables
both
51
while loop executes a given statement or block of statements repeatedly as long as the value of the expression is true.
False
True
52
InputStream is used to read data from a source; it may be a file, an array, peripheral device or socket.
True
False
53
Which feature can be implemented using encapsulation?
Abstraction
Polymorphism
Inheritance
Overloading
54
Which of the following is a correct difference between the Iterator and Enumeration?
b
c
a
d
55
A feature of Netbeans for supporting the J2EE 1.3 & 1.4 standards with web application build support based on Apache Ant
environment
project system
web development
56
Which statement(s) is false about following program?
courseProvider.equals(courseProvider==firstName+lastName) will be true
courseProvider.equals(courseProvider==firstName+lastName) will be to false
courseProvider.equals(FullName) will evaluate to true.
courseProvider==FullName will evaluate to true.
57
Which of the following classes fail to compile?
X
All classes compile
Y
Z
58
OOP describes the task to be performed on objects.
False
True
59
The java.util.io package contains all the classes required for input and output operations.
True
False
60
An IDE doesn't have version control system
False
True
61
What is the name of the class in this program:
System
String args
main
Square
62
"\new" is an escape character for new line.
True
False
63
What is an array?
A random integer
A sequence of values.
May contains elements with different data types.
64
What type of inheritance does Java have?
Single Inheritance
Double Inheritance
Multiple Inheritance
Class Inheritance
65
What will be the output of the program?
An AssertionError is thrown and finished is output.
finished
Compiliation fails.
An AssertionError is thrown with the message "assertion failed."
66
A file that is compiled to produce bytecode file
word file
procedures
java source code
class file
67
This the standard output stream.
System.err
System.out
System.in
68
It divides left operand with the right operand and assign the result to left operand.
+=
/=
-=
*-
69
James Gosling works for what company when they developed java?
microsoft
oracle
none of the options
sun microsystems
70
It adds right operand to the left operand and assign the result to left operand.
/=
*-
+=
-=
71
true or false
True
False
72
An IDE has build-automation tools.
False
True
73
When Overloading does not occur?
c
a
b
d
74
main method is int because the Java interpreter does not expect to receive or process any output from the class.
False
True
75
System is a method
False
True
76
Which List would you use if wanted fast access and were doing lots of insertions and deletions?
LinkedList
ArrayList
Vector
77
The main method is static because it must be called before the class that hosts the method is instantiated
True
False
78
An abstract class cannot have instance data and non-abstract methods.
True
False
79
What is the output of the following code fragment:
The program is defective and will not compile.
0 34 88
34 88 88
34 88 0
80
Abstraction principle includes___________
Use abstraction whenever possible to avoid duplication
Use abstraction to avoid longer codes
Use abstraction at its minimum
Use abstraction whenever possible to achieve OOP
81
What is the EXACT output:
4 5 176
4 5 267
4 5 316
4 5 266
82
Which among the following violates the principle of encapsulation almost always?
Array variables
Local variables
Public variables
Global variables
83
nextBool() reads a boolean value from the user.
False
True
84
Consider the following codes:
2
4
3
1
85
What is the output of the following code fragment:
4
4 3
3 7
1
86
What must the change be so that the following fragment prints out the even integers 0 2 4 6 8 10?
j++++
++j++
j+2
j = j+2
87
Abstraction can apply to ____________
Only data
Control and data
Classes
Only control
88
What is the correct difference between HashSet and HashMap?
HashSet can contain dup elements while HashMap contains only unique element
HashSet contains only values while HashMap contains the key and value pair
HashSet maintains no order whereas HashMap maintains ascending order.
89
What will be the output of the program?
finished
An AssertionError is thrown with the message "assertion failed."
An AssertionError is thrown and finished is output.
compilation fails
90
String str = "Hot Java"; boolean switch = str instanceof String; What value is placed in switch?
true
null
false
"Hot Java"
91
int has a width of 8 bytes
False
True
92
The System class is not a part of the core Java language package of the Application Programming Interface (API)
True
False
93
Which among the following would destroy the encapsulation mechanism if it was allowed in programming?
Using access declaration for global variables
Using access declaration for public members of base class
Using access declaration for local variable of main() function
Using access declaration for private members of base class
94
Identifiers are names that are given by the programmer as name of variables, methods or functions, classes etc
False
True
95
double data type has a width of 8 in bytes.
False
True
96
What are the two types of Polymorphism?
Constructor and method
derive and base
Syntax and runtime
encapsulation and Inheritance
97
statements associated with
else
is executed if the value of the switch variable does not match any of the case constants
True
False
98
The Scanner class contains a method called ___________ that reads user input that is a integer.
length()
Println
NextInt
pow
99
What must be true if a child of an abstract parent class does not override all of the parent's abstract methods?
Child classes are automatically non-abstract, so this is OK.
The child class itself must be declared to be abstract.
This is always an error.
The parent class is in error.
100
The _____ loop is for traversing items in a collection
do while
foreach
for
while