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

51
Q

StringBuilder has a method trim()

52
Q

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

53
Q

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

54
Q

The class string has a method .intern()

55
Q

ArrayList can take duplicate values

56
Q

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

57
Q

An else statement without an if block doesn’t compile

58
Q

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

59
Q

Switch can take long, float or double

60
Q

Switch can take booleans

61
Q

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

62
Q

Enhanced for loop has a counter variable for the position

63
Q

A class variable is not static

64
Q

The main method can throw exceptions

65
Q

Top-level classes cannot be private, protected or static

66
Q

An abstract class doesn’t need to have abstract methods

67
Q

Abstract methods can’t be in a normal class

68
Q

Abstract methods don’t have body

69
Q

An interface can be final

70
Q

A final method can be overridden

71
Q

Static methods can’t be abstract

72
Q

Static methods can use non-static variables

73
Q

A byte fits in an int

74
Q

= has precendence over ==

75
Q

Methods can return an interface

76
Q

ArrayIndexOutOfBoundsException is a subclass of IndexOutOfBoundsException

77
Q

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

78
Q

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

79
Q

String has the method reverse()

80
Q

String has the method hasCode()

81
Q

An interface can extend another interface

82
Q

A class can be synchronized

83
Q

String class is final

84
Q

StringBuilder class is final

85
Q

Integer class is final

86
Q

java.lang.system class is final

87
Q

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

88
Q

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

89
Q

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

90
Q

an overriding method might return a different type

91
Q

ensureCapacity() is a method of StringBuilder

92
Q

setLength() is a method of StringBuilder

93
Q

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

94
Q

Only methods can be native

95
Q

Static methods may or may not be abstract

96
Q

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

97
Q

/, * and % have the same level of precedence

98
Q

% can only be used with integer operands

99
Q

You can define a member variable as private static final transient

100
Q

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

101
Q

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

102
Q

A class cannot override a super-class’ constructor

103
Q

Constructors cannot be abstract

104
Q

Constructors cannot have empty bodies

105
Q

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

106
Q

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

107
Q

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

108
Q

Dynamic binding is an outcome of polymorphism

109
Q

Encapsulation helps you inherit the properties of another class

110
Q

assert is a keyword in java

111
Q

const is a keyword in java

112
Q

Members of an interface may be static

113
Q

The methods of an interface are static

114
Q

instanceof is a java operator

115
Q

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

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

117
Q

StackOverflowError and OutOfMemoryError ar subclasses of VirtualMachineError

118
Q

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

119
Q

MemoryOutOfBounds exception is a subclass of RuntimeException

120
Q

An abstract class cannot implement an interface

121
Q

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

122
Q

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

123
Q

Is it possible to create arrays of length zero