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
Q

The following is valid: static import java.lang.System.*;

A

False

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

A variable can be synchronized

A

False

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

A local variable can be volatile

A

False

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

A constructor can be final

A

False

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

A local variable can be transient

A

False

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

Only member variables can be volatile

A

True

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

Only member variables can be transient

A

True

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

A constructor can be static

A

False

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

A constructor can be abstract

A

False

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

ArrayList extends java.util.AbstractList

A

True

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

System.gc() suggests JVM to do garbage collection

A

True

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

Static methods are not overridden, but shadowed

A

True

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

strictfp is a keyword in java

A

True

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

do is a keyword in java

A

True

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

unsigned is a keyword in java

A

False

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

A short can be assigned to a char without casting

A

False

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

We cannot use this/super in static methods

A

True

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

The variables of an interface are public, final and static

A

True

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

The methods of an interface are public and abstract

A

True

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

The methods of an interface can be final

A

False

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

The methods of an interface can be static

A

False

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

A derived class is abstract if it doesn’t implement all the abstract methods of it’s based class

A

True

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

length() is a method of the Array class

A

False

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

length() is a method of the String class

A

True

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

StringBuilder has a method concat()

A

False

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

String has a method append()

A

False

51
Q

StringBuilder has a method trim()

A

False

52
Q

The method append() of StringBuilder can take a String, char[ ], Boolean)

A

True

53
Q

The method substring() of String takes only int or char

A

True

54
Q

The class string has a method .intern()

A

True

55
Q

ArrayList can take duplicate values

A

True

56
Q

Method clone() of ArrayList creates a copy in a different object and the elements inside it point at the same place

A

True

57
Q

An else statement without an if block doesn’t compile

A

True

58
Q

An if statement without a block of code doesn’t compile

A

False

59
Q

Switch can take long, float or double

A

False

60
Q

Switch can take booleans

A

False

61
Q

Enhanced for loop cannot be used within a do-while loop

A

True

62
Q

Enhanced for loop has a counter variable for the position

A

False

63
Q

A class variable is not static

A

False

64
Q

The main method can throw exceptions

A

True

65
Q

Top-level classes cannot be private, protected or static

A

True

66
Q

An abstract class doesn’t need to have abstract methods

A

True

67
Q

Abstract methods can’t be in a normal class

A

True

68
Q

Abstract methods don’t have body

A

True

69
Q

An interface can be final

A

False

70
Q

A final method can be overridden

A

False

71
Q

Static methods can’t be abstract

A

True

72
Q

Static methods can use non-static variables

A

False

73
Q

A byte fits in an int

A

True

74
Q

= has precendence over ==

A

False

75
Q

Methods can return an interface

A

True

76
Q

ArrayIndexOutOfBoundsException is a subclass of IndexOutOfBoundsException

A

True

77
Q

To access a superclass variable that is shadowed you can use casting

A

True

78
Q

To access a superclass method that is shadowed you can use casting

A

False

79
Q

String has the method reverse()

A

False

80
Q

String has the method hasCode()

A

True

81
Q

An interface can extend another interface

A

True

82
Q

A class can be synchronized

A

False

83
Q

String class is final

A

True

84
Q

StringBuilder class is final

A

True

85
Q

Integer class is final

A

True

86
Q

java.lang.system class is final

A

True

87
Q

a constructor must throw the exception of its base class constructor or a super exception

A

True

88
Q

an overriding method can throw a super class exception of the base method’s exception

A

False

89
Q

an overriding method must return the same type if it’s a primitive

A

True

90
Q

an overriding method might return a different type

A

True

91
Q

ensureCapacity() is a method of StringBuilder

A

True

92
Q

setLength() is a method of StringBuilder

A

True

93
Q

if a base-class method is set as default, the overriding method can be set protected

A

True

94
Q

Only methods can be native

A

True

95
Q

Static methods may or may not be abstract

A

False

96
Q

& can have integral and Boolean operands but && can only have Boolean operands

A

True

97
Q

/, * and % have the same level of precedence

A

True

98
Q

% can only be used with integer operands

A

False

99
Q

You can define a member variable as private static final transient

A

True

100
Q

Integer values can be used in the condition of an if statement

A

False

101
Q

An overriding method may opt not to declare any throws clause even if the original method has a throws clause

A

True

102
Q

A class cannot override a super-class’ constructor

A

True

103
Q

Constructors cannot be abstract

A

True

104
Q

Constructors cannot have empty bodies

A

True

105
Q

Encapsulation helps make sure that clients have no accidental dependence on the choice of representation

A

True

106
Q

Encapsulation helps avoiding name clashes as internal variables are not visible outside

A

True

107
Q

Encapsulation makes sure that messages are sent to the right object at run time

A

False

108
Q

Dynamic binding is an outcome of polymorphism

A

True

109
Q

Encapsulation helps you inherit the properties of another class

A

False

110
Q

assert is a keyword in java

A

True

111
Q

const is a keyword in java

A

True

112
Q

Members of an interface may be static

A

True

113
Q

The methods of an interface are static

A

False

114
Q

instanceof is a java operator

A

True

115
Q

You can sort the elements of an ArrayList using Collection.sort()

A

True

116
Q

You must specify the class of the objects you want to store in an ArrayList when you declare a variable of type ArrayList

A

False

117
Q

StackOverflowError and OutOfMemoryError ar subclasses of VirtualMachineError

A

True

118
Q

new StringBuilder() creates an object of StringBuilder with capacity for 16 chars

A

True

119
Q

MemoryOutOfBounds exception is a subclass of RuntimeException

A

False

120
Q

An abstract class cannot implement an interface

A

False

121
Q

A concrete class can be extended by an abstract or a concrete class

A

True

122
Q

double/float/long/boolean are invalid in a switch

A

True

123
Q

Is it possible to create arrays of length zero

A

True