Set-1 Java - Answers
Set-1 Java - Answers
a. Dynamic
b. Architecture Neutral
c. Use of pointers
d. Object-oriented
○ One of the major factors of not using pointers in Java is security concerns. Due
to pointers, most of the users consider C-language very confusing and complex.
This is the reason why Green Team (Java Team members) has not introduced
pointers in Java.
a. JDK
b. JVM
c. JRE
d. JIT
Answer: JDK
Explanation: Get the concepts clear at: https://www.ibm.com/blog/jvm-vs-jre-vs-jdk/
a. -3.4e+050
b. +1.7e+3,08
c. -3.4e+038
d. -1.7e+308
Answer: -3.4e+038
Topic: Primitive DataType
Explanation: Get the concepts clear at:
https://cs.fit.edu/~ryan/java/language/java-data.html
Answer: 0 to 65535
Explanation: Char occupies 16-bit in memory, so it supports 216 i:e from 0 to 65535.
Topic: Primitive DataType
Get the concepts clear at: https://cs.fit.edu/~ryan/java/language/java-data.html
5. What is BigDecimal.ONE?
6. When an expression consists of int, double, long, float, then the entire expression will
get promoted into a data type that is ?
a. Float
b. Double
c. Int
d. long
Answer: Double
Topic: Type casting
Explanation: Get the concepts clear at: Type-conversion-and-casting
a. C&B
b. A&D
c. A,B&D
d. A,B&C
Answer: A,B&C
Topic: Operators
Explanation: Get the concepts clear at: https://data-flair.training/blogs/java-operators/
A. main() method
B. The first line of code
C. Last line of code
D. main class
Explanation: Generally, the main() method is treated as the point where the flow of
code starts.
Get the concepts clear at: How to declare and initialize an array in Java?
Explanation: In Java, arrays are objects, they have members like length. The length
member is final and cannot be changed. All objects are allocated on heap in Java, so
arrays are also allocated on heap.
Answer: .class
14. What will be the output of the following Java program?
class output
{
public static void main(String args[])
{
StringBuffer s1 = new StringBuffer("Quiz");
StringBuffer s2 = s1.reverse();
System.out.println(s2);
}
}
a) QuizziuQ
b) ziuQQuiz
c) Quiz
d) ziuQ
Answer: d
Explanation: reverse() method reverses all characters. It returns the reversed object on
which it was called.
Get the concepts clear at: https://www.studytonight.com/java/stringbuffer-class.php
15. Which of the following is false about the abstract classes in java?
a. If we derive an abstract class and do not implement all the abstract methods,
then the derived class should also be marked as abstract using 'abstract'
keyword.
b. Abstract classes can have constructors.
c. A class can be made abstract without any abstract method.
d. A class can inherit from multiple abstract classes.
class Output
{
public static void main(String args[])
{
double x = 3.14;
int y = (int) Math.ceil(x);
System.out.print(y);
}
}
a. 3
b. 0
c. 4
Answer: 4
Explanation: ciel(double X) returns the smallest whole number greater than or equal to
variable x.
a) [A, D, C]
b) [A, B, C]
c) [A, B, C, D]
d) [A, D, B, C]
Answer: [A, D, B, C]
Get the concepts clear at: https://www.baeldung.com/java-arraylist
Video: https://www.youtube.com/watch?v=NbYgm0r7u6o
18. What is the IEEE standard adopted to represent Floating point numbers in
Java?
a. IEEE9000
b. IEEE800
c. IEEE754
d. IEEE512
Answer: IEEE754
Explanation: IEEE stands for Institute of Electrical and Electronics Engineers. Original
specifications were defined in the year 1985. The current version includes
improvements or corrections done in the year 2008.
a. ASCII
b. Unicode
c. Hexacode
d. Bytecode
Answer: Unicode
Explanation: Unicode takes 2 Bytes (16 bits) of memory to represent all characters of
all languages.
20. Choose a correct rule for using Underscores in literals of Java language.
a. Underscores cannot come at the end of a number or next to the last digit of a
number.
b. Underscores cannot come at the beginning of a number or before the first digit of
a number.
c. Underscores cannot come before or after a decimal point in real numbers like
float and double.
d. All the above
int p = 10;
P = p%3;
a. p=%3;
b. p%=3;
c. p=3%;
d. None of the above
Answer: p%=3;
22. Between Postfix and Prefix arithmetic operators in Java, which operators have
more priority?
A. extends
B. inheritance
C. isChild
D. None of these
Answer: A) extends