True/false game Flashcards

1
Q

2Next is a legal identifier.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Non static methods can access static as well as non static methods of a class.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

do is a keyword so do() is not a valid method name.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

A class having no abstract method can’t still be abstract. But not vice-versa.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

A class having no abstract method can still be abstract. But not vice-versa.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

final static public void main (String[ ] arguments ) { } is valid.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

InputException and MemoryException are valid exceptions in Java

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

FileNotFoundException and SecurityException are valid exceptions in Java

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

If a.equals(b) returns true, b instanceof ClassOfA must always be true.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

The array consumes less memory than the ArrayList

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Accessing an element in an array is faster than in ArrayList.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

arrays implements Collection Interface

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Accessing implements Collection Interface

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

A “default” constructor calls the no-args constructor of the super class.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

float f = -123; is valid

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

It is not possible to create arrays of length zero

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

A static method can’t access non-static instance variables of a class.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

StringBuilder sb1 = new StringBuilder() will create a StringBuilder object with no characters, but with an initial capacity to store 16 chars.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

StringBuilder sb1 = new StringBuilder(5*10) will create a StringBuilder object with a value 50.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

The insert method can be used to insert a character, number, or String at the start or end or a specified position of a StringBuilder.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

A class can’t define multiple main methods.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

More than one class in an application can define the main method.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

The main method may accept a String, a String array, or varargs (String… arg) as a method argument.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

The main method shouldn’t define an object of the class in which the main method itself is defined.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
The following is valid: static import java.lang.System.*;
False
26
A variable can be synchronized
False
27
A local variable can be volatile
False
28
A constructor can be final
False
29
A local variable can be transient
False
30
Only member variables can be volatile
True
31
Only member variables can be transient
True
32
A constructor can be static
False
33
A constructor can be abstract
False
34
ArrayList extends java.util.AbstractList
True
35
System.gc() suggests JVM to do garbage collection
True
36
Static methods are not overridden, but shadowed
True
37
strictfp is a keyword in java
True
38
do is a keyword in java
True
39
unsigned is a keyword in java
False
40
A short can be assigned to a char without casting
False
41
We cannot use this/super in static methods
True
42
The variables of an interface are public, final and static
True
43
The methods of an interface are public and abstract
True
44
The methods of an interface can be final
False
45
The methods of an interface can be static
False
46
A derived class is abstract if it doesn’t implement all the abstract methods of it’s based class
True
47
length() is a method of the Array class
False
48
length() is a method of the String class
True
49
StringBuilder has a method concat()
False
50
String has a method append()
False
51
StringBuilder has a method trim()
False
52
The method append() of StringBuilder can take a String, char[ ], Boolean)
True
53
The method substring() of String takes only int or char
True
54
The class string has a method .intern()
True
55
ArrayList can take duplicate values
True
56
Method clone() of ArrayList creates a copy in a different object and the elements inside it point at the same place
True
57
An else statement without an if block doesn’t compile
True
58
An if statement without a block of code doesn’t compile
False
59
Switch can take long, float or double
False
60
Switch can take booleans
False
61
Enhanced for loop cannot be used within a do-while loop
True
62
Enhanced for loop has a counter variable for the position
False
63
A class variable is not static
False
64
The main method can throw exceptions
True
65
Top-level classes cannot be private, protected or static
True
66
An abstract class doesn’t need to have abstract methods
True
67
Abstract methods can’t be in a normal class
True
68
Abstract methods don’t have body
True
69
An interface can be final
False
70
A final method can be overridden
False
71
Static methods can’t be abstract
True
72
Static methods can use non-static variables
False
73
A byte fits in an int
True
74
= has precendence over ==
False
75
Methods can return an interface
True
76
ArrayIndexOutOfBoundsException is a subclass of IndexOutOfBoundsException
True
77
To access a superclass variable that is shadowed you can use casting
True
78
To access a superclass method that is shadowed you can use casting
False
79
String has the method reverse()
False
80
String has the method hasCode()
True
81
An interface can extend another interface
True
82
A class can be synchronized
False
83
String class is final
True
84
StringBuilder class is final
True
85
Integer class is final
True
86
java.lang.system class is final
True
87
a constructor must throw the exception of its base class constructor or a super exception
True
88
an overriding method can throw a super class exception of the base method’s exception
False
89
an overriding method must return the same type if it’s a primitive
True
90
an overriding method might return a different type
True
91
ensureCapacity() is a method of StringBuilder
True
92
setLength() is a method of StringBuilder
True
93
if a base-class method is set as default, the overriding method can be set protected
True
94
Only methods can be native
True
95
Static methods may or may not be abstract
False
96
& can have integral and Boolean operands but && can only have Boolean operands
True
97
/, * and % have the same level of precedence
True
98
% can only be used with integer operands
False
99
You can define a member variable as private static final transient
True
100
Integer values can be used in the condition of an if statement
False
101
An overriding method may opt not to declare any throws clause even if the original method has a throws clause
True
102
A class cannot override a super-class’ constructor
True
103
Constructors cannot be abstract
True
104
Constructors cannot have empty bodies
True
105
Encapsulation helps make sure that clients have no accidental dependence on the choice of representation
True
106
Encapsulation helps avoiding name clashes as internal variables are not visible outside
True
107
Encapsulation makes sure that messages are sent to the right object at run time
False
108
Dynamic binding is an outcome of polymorphism
True
109
Encapsulation helps you inherit the properties of another class
False
110
assert is a keyword in java
True
111
const is a keyword in java
True
112
Members of an interface may be static
True
113
The methods of an interface are static
False
114
instanceof is a java operator
True
115
You can sort the elements of an ArrayList using Collection.sort()
True
116
You must specify the class of the objects you want to store in an ArrayList when you declare a variable of type ArrayList
False
117
StackOverflowError and OutOfMemoryError ar subclasses of VirtualMachineError
True
118
new StringBuilder() creates an object of StringBuilder with capacity for 16 chars
True
119
MemoryOutOfBounds exception is a subclass of RuntimeException
False
120
An abstract class cannot implement an interface
False
121
A concrete class can be extended by an abstract or a concrete class
True
122
double/float/long/boolean are invalid in a switch
True
123
Is it possible to create arrays of length zero
True