Java Data Types, Variables and Arrays Mcqs
Our collections of Multiple choice questions and answers focuses on study of Java Data Types, Variables and Arrays . These questions are chosen from a collection of most authoritative and best reference books on Java Data Types, Variables and Arrays. Our aim is to prepare an individual for competitive exams like NTS, GAT, ECAT, University and College entrance exams and various tests and job interviews. One should practice our Mcqs to assimilate Data Types, Variables and Arrays comprehensively.
Java Programming Mcqs
- Data Types Variables and Arrays Mcqs
- Exception Handling in Java Mcqs
- Interfaces and Packages Mcqs
- Java Classes and Methods Mcqs
- Java Event Handling Mcqs
- Java Inheritance Mcqs
- Java IO and Applets Mcqs
- java lang and java io Mcqs
- Java Language Fundamentals Mcqs
- Java Operators and Control Statements Mcqs
- java utilities Mcqs
- Miscellaneous Topics in Java Mcqs
- Multithreading in Java Mcqs
- Serialization and Networking Mcqs
- Session Management and JSP and Servlet Mcqs
- String Handling
Computer MCQS
Sciences MCQS
2. What is the output of below code snippet?
class A
{
}
enum Enums extends A
{
ABC, BCD, CDE, DEF;
}
class A
{
}
enum Enums extends A
{
ABC, BCD, CDE, DEF;
}
Runtime Error
Compilation Error
It runs successfully
EnumNotDefined Exception
Answer & Solution
No Solution for this Answer..! Report or Discus this Question
3. What is the output of below code snippet?
enum Levels
{
private TOP,
public MEDIUM,
protected BOTTOM;
}
enum Levels
{
private TOP,
public MEDIUM,
protected BOTTOM;
}
Runtime Error
EnumNotDefined Exception
It runs successfully
Compilation Error
Answer & Solution
No Solution for this Answer..! Report or Discus this Question
4. What is the output of below code snippet?
enum Enums
{
A, B, C;
private Enums()
{
System.out.println(10);
}
}
public class MainClass
{
public static void main(String[] args)
{
Enum en = Enums.B;
}
}
enum Enums
{
A, B, C;
private Enums()
{
System.out.println(10);
}
}
public class MainClass
{
public static void main(String[] args)
{
Enum en = Enums.B;
}
}
10 10 10
Compilation Error
10 10
Runtime Exception
Answer & Solution
No Solution for this Answer..! Report or Discus this Question
5. Which method returns the elements of Enum class?
GetEnums()
GetEnumConstants()
GetEnumList()
GetEnum()
Answer & Solution
No Solution for this Answer..! Report or Discus this Question
6. Which class does all the Enums extend?
Object
Enums
Enum
EnumClass
7. Which of the following is the advantage of BigDecimal over double?
Syntax
Memory usage
Garbage creation
Precision
Answer & Solution
No Solution for this Answer..! Report or Discus this Question
9. What is the output of below code snippet?
enum Enums
{
A, B, C;
private Enums()
{
System.out.println(10);
}
}
public class MainClass
{
public static void main(String[] args)
{
Enum en = Enums.B;
}
}
enum Enums
{
A, B, C;
private Enums()
{
System.out.println(10);
}
}
public class MainClass
{
public static void main(String[] args)
{
Enum en = Enums.B;
}
}
0.009999999999999998 0.01
0.01 0.009999999999999998
0.01 0.01
0.009999999999999998 0.009999999999999998
Answer & Solution
No Solution for this Answer..! Report or Discus this Question
10. What is the base of BigDecimal data type?
Base 2
Base 8
Base 10
Base e
11. What is the limitation of toString() method of BigDecimal?
There is no limitation
ToString returns null
ToString returns the number in expanded form
ToString uses scientific notation
Answer & Solution
No Solution for this Answer..! Report or Discus this Question
12. Which of the following is not provided by BigDecimal?
Scale manipulation
+ operator
Rounding
Hashing
Answer & Solution
No Solution for this Answer..! Report or Discus this Question
13. BigDecimal is a part of which package?
Java.lang
Java.math
Java.util
Java.io
Answer & Solution
No Solution for this Answer..! Report or Discus this Question
14. What is BigDecimal.ONE?
Wrong statement
Custom defined statement
Static variable with value 1 on scale 10
Static variable with value 1 on scale 0
Answer & Solution
No Solution for this Answer..! Report or Discus this Question
15. Which class is a library of functions to perform arithmetic operations of BigInteger and BigDecimal?
MathContext
MathLib
BigLib
BigContext
Answer & Solution
No Solution for this Answer..! Report or Discus this Question
16. What is the output of below code snippet?
public class AddDemo
{
public static void main(String args[])
{
BigDecimal b = new BigDecimal("23.43");
BigDecimal br = new BigDecimal("24");
BigDecimal bres = b.add(new BigDecimal("450.23"));
System.out.println("Add: "+bres);
MathContext mc = new MathContext(2, RoundingMode.DOWN);
BigDecimal bdecMath = b.add(new BigDecimal("450.23"), mc);
System.out.println("Add using MathContext: "+bdecMath);
}
}
public class AddDemo
{
public static void main(String args[])
{
BigDecimal b = new BigDecimal("23.43");
BigDecimal br = new BigDecimal("24");
BigDecimal bres = b.add(new BigDecimal("450.23"));
System.out.println("Add: "+bres);
MathContext mc = new MathContext(2, RoundingMode.DOWN);
BigDecimal bdecMath = b.add(new BigDecimal("450.23"), mc);
System.out.println("Add using MathContext: "+bdecMath);
}
}
Compilation failure
Add: 684.66 Add using MathContext: 6.8E+2
Runtime exception
Add 6.8E+2 Add using MathContext: 684.66
Answer & Solution
No Solution for this Answer..! Report or Discus this Question