Java PartA All Units 1Mark QA
Java PartA All Units 1Mark QA
Answer: Converting one data type into another (e.g., int to float).
Answer: Pass input values to the main method using String[] args.
Answer: while checks condition first; do-while runs once before checking.
Answer: Both have same name but different parameters; constructors initialize objects.
8. What is the significance of the final keyword in Java classes and methods?
Answer: Java passes all arguments by value (object references are passed by value).
int factorial(int n) {
if(n == 1) return 1;
Answer: A data structure to store multiple values of same type in a single variable.
Answer: Abstract classes can have method bodies; interfaces only have abstract methods (before
Java 8).
Answer: Single, Multilevel, Hierarchical (Java doesn't support multiple inheritance with classes).
Answer: Same method behaves differently based on the object (via overloading and overriding).
Answer: Interface has only abstract methods; class has fields and methods with implementation.
3. What are access modifiers, and how do they affect member access in a package?
Answer: They control visibility of class members: public, private, protected, default.
9. What is the difference between byte stream classes and character stream classes?
Answer: Byte stream handles binary data, character stream handles text data.
7. How do you create a new thread in Java using the Thread class?