InterviewSolution
This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.
| 1. |
Which of these is an incorrect Statement?(a) It is necessary to use new operator to initialize an array(b) Array can be initialized using comma separated expressions surrounded by curly braces(c) Array can be initialized when they are declared(d) None of the mentionedI got this question in an interview.My question is based upon Arrays topic in section Data Types, Variables and Arrays of Java |
|
Answer» Right answer is (a) It is necessary to use new operator to initialize an array |
|
| 2. |
Which of these is an incorrect array declaration?(a) int arr[] = new int[5](b) int [] arr = new int[5](c) int arr[] = new int[5](d) int arr[] = int [5] newThe question was asked during an interview.My doubt is from Arrays topic in chapter Data Types, Variables and Arrays of Java |
|
Answer» CORRECT choice is (d) int arr[] = int [5] new Easy explanation: Operator new must be SUCCEEDED by array TYPE and array SIZE. |
|
| 3. |
If an expression contains double, int, float, long, then the whole expression will be promoted into which of these data types?(a) long(b) int(c) double(d) floatI got this question in unit test.The question is from Type Conversions, Promotions and Castings topic in chapter Data Types, Variables and Arrays of Java |
|
Answer» Correct choice is (C) double |
|
| 4. |
Which of these operators is used to allocate memory to array variable in Java?(a) malloc(b) alloc(c) new(d) new mallocThis question was addressed to me at a job interview.The above asked question is from Arrays topic in section Data Types, Variables and Arrays of Java |
|
Answer» Right choice is (c) new |
|
| 5. |
Which of these is necessary condition for automatic type conversion in Java?(a) The destination type is smaller than source type(b) The destination type is larger than source type(c) The destination type can be larger or smaller than source type(d) None of the mentionedThe question was posed to me in an interview.Question is taken from Type Conversions, Promotions and Castings in division Data Types, Variables and Arrays of Java |
|
Answer» RIGHT OPTION is (B) The destination type is larger than SOURCE type To elaborate: None. |
|
| 6. |
Which of these can be returned by the operator &?(a) Integer(b) Boolean(c) Character(d) Integer or BooleanI got this question in exam.My question comes from Literals & Variables topic in division Data Types, Variables and Arrays of Java |
|
Answer» Right choice is (d) INTEGER or BOOLEAN |
|
| 7. |
How to get difference between two dates?(a) long diffInMilli = java.time.Duration.between(dateTime1, dateTime2).toMillis();(b) long diffInMilli = java.time.difference(dateTime1, dateTime2).toMillis();(c) Date diffInMilli = java.time.Duration.between(dateTime1, dateTime2).toMillis();(d) Time diffInMilli = java.time.Duration.between(dateTime1, dateTime2).toMillis();I got this question in quiz.This key question is from Data Type-Date, TimeZone topic in chapter Data Types, Variables and Arrays of Java |
|
Answer» The correct option is (a) long diffInMilli = java.time.Duration.between(dateTime1, dateTime2).toMillis(); |
|
| 8. |
What does LocalTime represent?(a) Date without time(b) Time without Date(c) Date and Time(d) Date and Time with timezoneI have been asked this question at a job interview.This is a very interesting question from Data Type-Date, TimeZone topic in chapter Data Types, Variables and Arrays of Java |
|
Answer» Correct answer is (B) Time without DATE |
|
| 9. |
Which of these is long data type literal?(a) 0x99fffL(b) ABCDEFG(c) 0x99fffa(d) 99671246I have been asked this question in a national level competition.My enquiry is from Literals & Variables topic in section Data Types, Variables and Arrays of Java |
|
Answer» RIGHT choice is (a) 0x99fffL To explain: DATA type LONG literals are appended by an UPPER or LOWERCASE L. 0x99fffL is hexadecimal long literal. |
|
| 10. |
How is Date stored in database?(a) java.sql.Date(b) java.util.Date(c) java.sql.DateTime(d) java.util.DateTimeThis question was addressed to me at a job interview.My question is based upon Data Type-Date, TimeZone in division Data Types, Variables and Arrays of Java |
|
Answer» The correct choice is (a) java.sql.DATE |
|
| 11. |
BigDecimal is a part of which package?(a) java.lang(b) java.math(c) java.util(d) java.ioI had been asked this question in class test.The origin of the question is Data Type-BigDecimal topic in chapter Data Types, Variables and Arrays of Java |
|
Answer» The correct option is (B) java.math |
|
| 12. |
What is the replacement of joda time library in java 8?(a) java.time (JSR-310)(b) java.date (JSR-310)(c) java.joda(d) java.jodaTimeThis question was addressed to me by my college professor while I was bunking the class.I need to ask this question from Data Type-Date, TimeZone in chapter Data Types, Variables and Arrays of Java |
|
Answer» The correct CHOICE is (a) java.time (JSR-310) |
|
| 13. |
Which class does all the Enums extend?(a) Object(b) Enums(c) Enum(d) EnumClassThe question was posed to me in an interview for job.I would like to ask this question from Data Type-Enums in portion Data Types, Variables and Arrays of Java |
|
Answer» Right choice is (c) ENUM |
|
| 14. |
Which of the following is not provided by BigDecimal?(a) scale manipulation(b) + operator(c) rounding(d) hashingThis question was posed to me during an internship interview.This key question is from Data Type-BigDecimal topic in chapter Data Types, Variables and Arrays of Java |
|
Answer» RIGHT option is (b) + operator Best EXPLANATION: toBigInteger() converts BigDecimal to a BIGINTEGER.toBigIntegerExact() converts this BigDecimal to a BigInteger by checking for lost INFORMATION. |
|
| 15. |
Which method returns the elements of Enum class?(a) getEnums()(b) getEnumConstants()(c) getEnumList()(d) getEnum()The question was posed to me during an online exam.This intriguing question comes from Data Type-Enums in division Data Types, Variables and Arrays of Java |
|
Answer» The correct answer is (b) getEnumConstants() |
|
| 16. |
Which of these coding types is used for data type characters in Java?(a) ASCII(b) ISO-LATIN-1(c) UNICODE(d) None of the mentionedI had been asked this question during a job interview.The query is from Character and Boolean Data Types in chapter Data Types, Variables and Arrays of Java |
|
Answer» Right CHOICE is (c) UNICODE |
|
| 17. |
What is the order of variables in Enum?(a) Ascending order(b) Descending order(c) Random order(d) Depends on the order() methodThe question was posed to me in homework.I'd like to ask this question from Data Type-Enums in portion Data Types, Variables and Arrays of Java |
|
Answer» The CORRECT ANSWER is (a) Ascending order |
|
| 18. |
Which of these occupy first0 to 127 in Unicode character set used for characters in Java?(a) ASCII(b) ISO-LATIN-1(c) None of the mentioned(d) ASCII and ISO-LATIN1The question was asked in an international level competition.Enquiry is from Character and Boolean Data Types in portion Data Types, Variables and Arrays of Java |
|
Answer» The CORRECT option is (d) ASCII and ISO-LATIN1 |
|
| 19. |
Which of these values can a boolean variable contain?(a) True & False(b) 0 & 1(c) Any integer value(d) trueThe question was asked during an interview.My doubt stems from Character and Boolean Data Types topic in section Data Types, Variables and Arrays of Java |
|
Answer» Right option is (a) TRUE & False |
|
| 20. |
Which of these literals can be contained in float data type variable?(a) -1.7e+308(b) -3.4e+038(c) +1.7e+308(d) -3.4e+050I had been asked this question in an interview.This key question is from Integer and Floating Data Types in portion Data Types, Variables and Arrays of Java |
|
Answer» The correct ANSWER is (B) -3.4e+038 |
|
| 21. |
An expression involving byte, int, and literal numbers is promoted to which of these?(a) int(b) long(c) byte(d) floatThe question was posed to me in examination.This is a very interesting question from Integer and Floating Data Types topic in section Data Types, Variables and Arrays of Java |
|
Answer» Right choice is (a) int |
|
| 22. |
What is the range of byte data type in Java?(a) -128 to 127(b) -32768 to 32767(c) -2147483648 to 2147483647(d) None of the mentionedI had been asked this question in quiz.Asked question is from Integer and Floating Data Types in portion Data Types, Variables and Arrays of Java |
|
Answer» RIGHT choice is (a) -128 to 127 The best I can explain: BYTE occupies 8 BITS in memory. Its range is from -128 to 127. |
|
| 23. |
What is the range of short data type in Java?(a) -128 to 127(b) -32768 to 32767(c) -2147483648 to 2147483647(d) None of the mentionedThis question was posed to me in my homework.Origin of the question is Integer and Floating Data Types topic in portion Data Types, Variables and Arrays of Java |
|
Answer» Correct choice is (b) -32768 to 32767 |
|