Modern Programming Languages MCQs with Answers
Practice important Modern Programming Languages MCQs with answers and explanations.
Multiple Choice Questions
Q521: Which Java class is the base class for all classes?
- A: Object
- B: Class
- C: System
- D: Package
View Answer
A
Q522: Which of the following is not allowed in Java class constructors?
- A: Multiple constructors with different parameters
- B: Constructor overloading
- C: Constructors with return types
- D: Constructors without return types
View Answer
C
Q523: Which of the following is a valid way to initialize a String in Java?
- A: String s1 = "hello";
- B: String s2 = new String("hello");
- C: String s3 = String("hello");
- D: String s4 = new String;
View Answer
A
Q524: In Java, arrays of which type can be assigned to another array?
- A: Primitive arrays
- B: Any object arrays
- C: Interfaces arrays
- D: None of the above
View Answer
A
Q525: What does the term "aliasing" refer to in Java?
- A: Creating a new instance of an object
- B: Assigning the same reference to two variables
- C: Creating a copy of an array
- D: Overloading a method
View Answer
B
Q526: When casting from one primitive type to another in Java, which of the following could cause a loss of information?
- A: Implicit conversion
- B: Explicit casting
- C: Both implicit and explicit conversions
- D: None of the above
View Answer
B
Q527: If a field is declared `private` in Java, it can be accessed from:
- A: Anywhere in the program
- B: Only within the class
- C: Anywhere in the package
- D: Only from subclasses
View Answer
B
Q528: Which of the following is true about public fields in Java?
- A: They can be accessed anywhere in the program
- B: They can only be accessed within the same package
- C: They are only accessible from subclasses
- D: They cannot be accessed outside the class
View Answer
A
Q529: In Java, which method signature is used to declare a method that does not return any value?
- A: void methodName()
- B: empty methodName()
- C: void methodName(void)
- D: methodName(void)
View Answer
A
Q530: What is the effect of using the `new` keyword in Java?
- A: It creates an array
- B: It allocates memory for an object
- C: It creates a new method
- D: It initializes a primitive variable
View Answer
B