-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEasy.java
152 lines (151 loc) · 5.29 KB
/
Easy.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
package java_quiz;
public class Easy {
int n=20;
String que[] = new String[n];
char ans[] = new char[n];
Easy()
{
que[0] = "Which one of these lists contains only Java programming language keywords?"
+ "\nA. class, if, void, long, Int, continue"
+ "\nB. goto, instanceof, native, finally, default, throws"
+ "\nC. try, virtual, throw, final, volatile, transient"
+ "\nD. strictfp, constant, super, implements, do";
ans[0] = 'B';
que[1] = "Which is a valid keyword in java?\n" +
"A. interface\n" +
"B. string\n" +
"C. Float\n" +
"D. unsigned";
ans[1] = 'A';
que[2] = "Which is a reserved word in the Java programming language?\n" +
"A. method\n" +
"B. native\n" +
"C. subclasses\n" +
"D. reference";
ans[2] = 'B';
que[3] ="Which is the valid declarations within an interface definition?\n" +
"A. public double methoda();\n" +
"B. public final double methoda();\n" +
"C. static void methoda(double d1);\n" +
"D. protected void methoda(double d1);";
ans[3] = 'A';
que[4] = "Which one is a valid declaration of a boolean?\n" +
"A. boolean b1 = 0;\n" +
"B. boolean b2 = 'false';\n" +
"C. boolean b3 = false;\n" +
"D. boolean b4 = Boolean.false();" ;
ans[4] = 'C';
que[5] ="What is the numerical range of a char?\n" +
"A. -128 to 127\n" +
"B. -(2^15) to (2^15) - 1\n" +
"C. 0 to 32767\n" +
"D. 0 to 65535";
ans[5] = 'D';
que[6] = "Which of the following statements are true for inheritance in Java?\n" +
"A. The “extend” keyword is used to extend a class in java.\n" +
"B. You can extend multiple classes in java.\n" +
"C. Private members of the superclass are accessible to the subclass.\n" +
"D. We can’t extend Final classes in java.";
ans[6] = 'D';
que[7] = "Which of the below are not unchecked exceptions in java?\n" +
"A. RuntimeException\n" +
"B. ClassCastException\n" +
"C. NullPointerException\n" +
"D. IOException";
ans[7] = 'D';
que[8] = "What is the process by which we can control what parts of a program can "
+ "access the members of a class?\n" +
"A Polymorphism\n" +
"B Abstraction\n" +
"C Encapsulation\n" +
"D Recursion";
ans[8] = 'C';
que[9] = "What is byte code in Java?\n" +
"A. Code generated by a Java compiler\n" +
"B. Code generated by a Java Virtual Machine\n" +
"C. Name of Java source code file\n" +
"D. Block of code written inside a class";
ans[9] = 'A';
que[10] = "Which variables are created when an object is created with the use of the keyword 'new' " +
"and destroyed when the object is destroyed?\n" +
"A. Local variables\n" +
"B. Instance variables\n" +
"C. Class Variables\n" +
"D. Static variables";
ans[10] = 'B';
que[11] = "Evaluate the following Java expression, if x=3, y=5, and z=10:\r\n" +
"++z + y - y + z + x++\r\n" +
"A. 24\n" +
"B. 23\n" +
"C. 20\n" +
"D. 25";
ans[11] = 'A';
que[12] = "Which of these classes are the direct subclasses of the Throwable class?\n" +
"A. RuntimeException and Error class\n" +
"B. Exception and VirtualMachineError class\n" +
"C. Error and Exception class\n" +
"D. IOException and VirtualMachineError class";
ans[12] = 'C';
que[13] = "The wrapping up of data and functions into a single unit is called\n" +
"A. Encapsulation\n" +
"B. Abstraction\n" +
"C. Data Hiding\n" +
"D. Polymorphism";
ans[13] = 'A';
que[14] = "In Java, declaring a class abstract is useful\n" +
"A. To prevent developers from further extending the class\n" +
"B. When it doesn’t make sense to have objects of that class\n" +
"C. When default implementations of some methods are not desirable\n" +
"D. To force developers to extend the class not to use its capabilities";
ans[14] = 'B';
que[15] = "Which of the following is a member of the java.lang package?\n" +
"A. List\n" +
"B. Queue\n" +
"C. Math\n" +
"D. Stack";
ans[15] = 'B';
que[16] = "Which operator is used by Java run time implementations to free the memory "
+ "of an object when it is no longer needed?\n" +
"A. delete\n" +
"B. free\n" +
"C. new\n" +
"D. none of the mentioned";
ans[16] = 'D';
que[17] = "Which of the following classes can catch all exceptions which cannot be caught?\n" +
"A. RuntimeException\n" +
"B. Error\n" +
"C. Exception\n" +
"D. ParentException";
ans[17] = 'B';
que[18] = "What is not the use of “this” keyword in Java?\n" +
"A. Passing itself to another method\n" +
"B. Calling another constructor in constructor chaining\n" +
"C. Referring to the instance variable when local variable has the same name\n" +
"D. Passing itself to method of the same class";
ans[18] = 'D';
que[19] = "What is the order of precedence (highest to lowest) of following operators?\n" +
" 1. &\n" +
" 2. ^\n" +
" 3. ?:\n" +
"A. 1 -> 2 -> 3\n" +
"B. 2 -> 1 -> 3\n" +
"C. 3 -> 2 -> 1\n" +
"D. 2 -> 3 -> 1";
ans[19] = 'A';
}
public void display(int i)
{
System.out.println("\n"+que[i]+"\n");
}
public boolean answer(char a,int i)
{
if(a==ans[i])
return true;
else
return false;
}
public void right(int i)
{
System.out.println("Right answer is : "+ans[i]);
}
}