ST.
ANNE’S COLLEGE OF ENGINEERING AND TECHNOLOGY
Approved by AICTE, New Delhi. Affiliated to Anna University, Chennai
Accredited by NAAC
ANGUCHETTYPALAYAM, PANRUTI – 607 106.
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
IVA026-ADVANCED JAVA PROGRAMMING
ASSESSMENT QUESTIONS
TIME:1.00 HRS DATE :09-09-2024
ANSWER ALL THE QUESTIONS
1. What is the size of an int in Java?
A) 4 bytes
B) 8 bytes
C) 2 bytes
D) 1 byte
2. Which of the following is not a keyword in Java?
A) static
B) void
C) main
D) private
3. What is the correct syntax to output 'Hello World' in Java?
A) System.out.print('Hello World');
B) echo('Hello World');
C) Console.WriteLine('Hello World');
D) print('Hello World');
4. Which of the following is a valid declaration of a char in Java?
A) char c = "A";
B) char c = 'A';
C) char c = A;
D) char c = "A";
5. What is bytecode in Java?
A) Machine code
B) A code generated by the Java compiler
C) A code generated by the Java Virtual Machine
D) A type of data structure
1
6. Which of the following is a primitive data type in Java?
A) String
B) Boolean
C) Array
D) Class
7. Which method is used to start a Java program?
A) start()
B) run()
C) main()
D) execute()
8. Which of the following loops is guaranteed to execute at least once?
A) for loop
B) while loop
C) do-while loop
D) None of the above
9. What is the default value of a local variable in Java?
A) null
B) 0
C) garbage value
D) No default value
10. Which of the following is not a feature of Java?
A) Platform independence
B) Object-oriented
C) Robust
D) Pointer manipulation
11. What is an interface in Java?
A) A class that contains abstract methods
B) A class that contains only concrete methods
C) A blueprint that defines methods without implementing them
D) A special class that can be instantiated
12. What is JVM?
A) Java Virtual Machine
B) Java Vendor Machine
2
C) Java Variable Machine
D) Java Value Machine
13. Which of the following is used to allocate memory for an object in Java?
A) malloc
B) alloc
C) new
D) create
14. What is the return type of a constructor?
A) int
B) void
C) Same as class type
D) No return type
15. How are strings stored in Java?
A) As an array of characters
B) As immutable objects
C) As mutable objects
D) As pointers
16. Which of the following is a reserved keyword in Java?
A) array
B) goto
C) null
D) integer
17. What does the 'final' keyword mean when applied to a variable?
A) The value of the variable can change
B) The value of the variable cannot be changed
C) The variable can be inherited
D) The variable is a global variable
18. Which of these is not a type of constructor in Java?
A) Default constructor
B) Parameterized constructor
C) Copy constructor
D) Private constructor
3
19. What does the 'static' keyword mean in Java?
A) The variable or method is specific to an instance
B) The variable or method belongs to the class, not an instance
C) The variable or method can be changed at runtime
D) The variable or method is only accessible within the class
20. What is the output of the following
code? int x = 5;
System.out.println(x++);
A) 5
B) 6
C) Compilation error
D) Runtime error
21. What does OOP stand for?
A) Object Oriented Programming
B) Operator Overloading Programming
C) Object Operation Programming
D) Object Oriented Procedure
22. Which OOP concept is illustrated by the super keyword?
A) Inheritance
B) Encapsulation
C) Polymorphism
D) Abstraction
23. Which OOP principle focuses on restricting access to certain details of an object?
A) Inheritance
B) Polymorphism
C) Abstraction
D) Encapsulation
24. Which of the following is an example of polymorphism?
A) A class having multiple constructors
B) Method overloading
C) Method overriding
D) Both B and C
4
25. What is inheritance in Java?
A) Acquiring features of a class
B) Hiding details of implementation
C) Writing multiple methods with the same name
D) Creating objects from a class
26. Which of the following is true about abstract classes?
A) Abstract classes cannot have constructors
B) Abstract classes must have abstract methods
C) Abstract classes can have concrete methods
D) Abstract classes cannot be inherited
27. Which keyword is used to create an object in Java?
A) new
B) this
C) super
D) create
28. Which of the following is an example of encapsulation?
A) Declaring variables as private and using public getter/setter methods
B) A class inheriting another class
C) Overloading a method
D) Implementing an interface
29. Which of these is not a pillar of OOP?
A) Inheritance
B) Polymorphism
C) Function Overloading
D) Encapsulation
30. Which of the following can be used for dynamic method dispatch in Java?
A) Constructor
B) Abstract class
C) Interface
D) Both B and C
5
31. What is meant by method overriding?
A) Two methods with the same name but different parameters
B) A method in a subclass having the same signature as in its superclass
C) Declaring multiple methods with the same name
D) Changing the return type of a method in a subclass
32. What happens when a subclass defines a static method with the same
signature as a static method in its superclass?
A) Compile-time error
B) The superclass method is hidden
C) The superclass method is overridden
D) The subclass method is called at runtime
33. What is the purpose of the this keyword in Java?
A) Refers to the current object instance
B) Refers to the class constructor
C) Refers to the superclass
D) Refers to the current method
34. What does the final keyword indicate in Java?
A) A method cannot be overridden
B) A class cannot be inherited
C) A variable cannot be reassigned
D) All of the above
35. Which of the following is true about interfaces in Java?
A) They cannot have method bodies
B) A class can implement multiple interfaces
C) They can have private methods
D) They cannot extend other interfaces
36. What is meant by constructor chaining?
A) Calling one constructor from another constructor in the same class
B) Calling methods with the same name
C) Referring to a constructor in a different class
6
D) Calling multiple constructors at the same time
37. Which of the following is not an access modifier in Java?
A) public
B) private
C) protected
D) external
38. Which of the following statements is true about the Object class in Java?
A) It is the parent class of all classes in Java
B) It is the child class of every class in Java
C) It must be extended by every class in Java
D) It cannot be inherited
39. In which of the following situations would you use super() in Java?
A) To invoke a constructor of the superclass
B) To invoke a method of the superclass
C) To override a superclass method
D) To call a static method
40. Which of the following is not a feature of OOP?
A) Modularity
B) Dynamic Binding
C) Procedural Programming
D) Data Abstraction
41. Which keyword is used to declare an abstract method in Java?
A) void
B) abstract
C) new
D) static
42. Which of the following classes cannot be instantiated?
A) Abstract class
B) Concrete class
C) Nested class
D) Inner class
7
43. Which of the following concepts restricts access to an object's components?
A) Polymorphism
B) Abstraction
C) Encapsulation
D) Inheritance
44. What is an interface in Java?
A) A class that contains abstract methods
B) A class that contains only concrete methods
C) A blueprint that defines methods without implementing them
D) A special class that can be instantiated
45. What is the term for when multiple methods share the same name but
have different parameters?
A) Method overriding
B) Method overloading
C) Inheritance
D) Encapsulation
46. Which of the following is not true about Java constructors?
A) Constructors are called automatically when an object is created
B) Constructors can be inherited
C) Constructors do not have a return type
D) A class can have more than one constructor
47. Which of the following can be overloaded?
A) Methods
B) Constructors
C) Operators
D) Both A and B
48. Which of the following is true about inheritance in Java?
A) A subclass cannot access private members of the superclass
B) A subclass can inherit multiple superclasses
C) Private methods of a superclass can be overridden by a subclass
D) All methods of the superclass are inherited by the subclass
8
49. Which of the following access modifiers allows the most restricted access?
A) public
B) private
C) protected
D) Package-private
50. Which of the following methods is present in all Java classes?
A) toString()
B) main()
C) finalize()
D) Both A and C