NEW
Font size
WorksheetsTEST3
Total questions: 26
Worksheet time: 14mins
class Test {
static int x = 10;
static {
x += 5;
}
public static void main(String[] args) {
x++;
System.out.println(x);
}
}
A. 10
B. 15
C. 16
D. 17
class Test {
public static void main(String[] args) {
Integer a = 100;
Integer b = 100;
Integer c = 200;
Integer d = 200;
System.out.print(a == b);
System.out.print(" ");
System.out.print(c == d);
}
}
A. true true
B. false false
C. true false
D. false true
Which statement is true?
A. HashMap is synchronized
B. ArrayList is thread-safe
C. String is immutable
D. StringBuilder is thread-safe
String s = null;
System.out.println(s.length());
A. IllegalArgumentException
B. NullPointerException
C. StringIndexOutOfBoundsException
D. IOException
#include <stdio.h>
int main() {
int a[] = {10, 20, 30};
printf("%d", *(a + 1));
return 0;
}
A. 10
B. 20
C. Address
D. Error
Which is true?
A. Array name is a pointer
B. Pointer size depends on data type
C. void* cannot store address
D. char* pointer arithmetic increases by 1 byte
#include <stdio.h>
int main() {
int x = 10;
if (x = 5)
printf("True");
else
printf("False");
return 0;
}
#include <stdio.h>
int main() {
int x = 10;
if (x = 5)
printf("True");
else
printf("False");
return 0;
}
A. True
B. False
C. Error
D. 5
Which causes memory leak?
A. Using malloc()
B. Using free() twice
C. Forgetting free()
D. Using static variables
#include <stdio.h>
int main() {
int x = 0;
while (x++ < 5);
printf("%d", x);
return 0;
}
A. 5
B. 6
C. Infinite loop
D. Error
class Test {
public static void main(String[] args) {
main(null);
}
}
A. StackOverflowError
B. Prints nothing
C. Compile-time error
D. Runtime error
What is the output of the following code?
int x = 10; if (x > 5) { x += 5; } System.out.println(x);
C. 5
B. 15
D. 0
A. 10
Which of the following is false?
D. The main method is static
C. Java supports multiple inheritance through interfaces
B. Primitive types can be null
A. All objects in Java are created from classes
What will be the output of the following code?
String str = "Hello"; str = str.concat(" World"); System.out.println(str);
A. Hello
B. Hello World
C. HelloWorld
D. Error
What is the output of the following code?
int a = 5; int b = 10; System.out.println(a + b);
D. 10
A. 15
B. 510
C. 5
Which of the following is true regarding Java exceptions?
D. All exceptions are checked
C. Errors are a type of exception
B. Runtime exceptions must be caught
A. Checked exceptions are unchecked
What will be the output of the following code?
String str = "Java"; str = str.toLowerCase(); System.out.println(str);
D. Error
C. Java
B. java
A. JAVA
. Which is true?
A. malloc() initializes memory
B. calloc() allocates contiguous memory
C. realloc() frees old memory automatically
D. free(NULL) causes error
#include <stdio.h>
int main() {
printf("%d", 5["ABCDE"]);
return 0;
}
A. A
B. E
C. Compile-time error
D. Garbage
What is the default join in SQL?
A. LEFT JOIN
B. RIGHT JOIN
C. FULL JOIN
D. INNER JOIN
Which is not a programming paradigm?
A. Procedural
B. Object-Oriented
C. Functional
D. Sequential Memory
Which factor most affects time complexity?
A. Compiler
B. Hardware
C. Input size
D. Programming language
Which notation describes upper bound?
A. Ω (Omega)
B. Θ (Theta)
C. O (Big-O)
D. λ (Lambda)
Which concept allows platform independence?
A. Compiler
B. Interpreter
C. Virtual Machine
D. Assembler
Which OOPS principle focuses on what an object does, not how?
A. Encapsulation
B. Inheritance
C. Polymorphism
D. Abstraction
Which feature violates strict encapsulation?
A. Private members
B. Getter/Setter
C. Inheritance
D. Abstraction
Which type of inheritance causes diamond problem?
A. Single
B. Multilevel
C. Hierarchical
D. Multiple
