Skip to main content

Important Web Design and Development Short Questions

Chapter: 3
Question 1:
How does Java handle memory for primitive data types and objects?
Answer: In Java, primitive data types are stored on the stack, while objects are stored on the heap. Primitive data types are passed by value, and objects are passed by reference.
Chapter: 3
Question 2:
What is a wrapper class in Java?
Answer: A wrapper class in Java is an object that encapsulates a primitive data type, providing additional functionality such as conversion and size checking. For example, Integer is the wrapper class for the primitive int.
Chapter: 3
Question 3:
How do you convert a string to a numeric primitive data type in Java?
Answer: In Java, you can convert a string to a numeric primitive data type using the parseXxx method of the corresponding wrapper class. For example, int d = Integer.parseInt("532"); converts the string "532" to an integer.
Chapter: 3
Question 4:
How can you take input through a GUI in Java and display the output?
Answer: In Java, you can take input through a GUI using the JOptionPane.showInputDialog() method and display the output using the JOptionPane.showMessageDialog() method. The input is received as a string and can be converted to the desired data type.
Chapter: 4
Question 5:
What is object-oriented programming (OOP) in Java?
Answer: Java is fundamentally object-oriented, meaning that every line of code must be inside a class. Key OOP concepts like Encapsulation, Inheritance, and Polymorphism are fully supported in Java.
Chapter: 4
Question 6:
Define a class in object-oriented programming.
Answer: A class in OOP is a blueprint or prototype for objects. It defines the structure and behavior of objects, similar to how a map represents a building.
Chapter: 4
Question 7:
What is an object in OOP?
Answer: An object is an instance of a class, representing a real-world entity. It is created from a class and can have attributes and methods.
Chapter: 4
Question 8:
What is a constructor in Java?
Answer: A constructor is a special method in Java used to create and initialize an object of a class. It has the same name as the class and does not return a value.
Chapter: 4
Question 9:
How does Java handle memory management?
Answer: Java handles memory management automatically through garbage collection, which reclaims memory used by objects that are no longer referenced.
Chapter: 4
Question 10:
What is the purpose of access modifiers in Java?
Answer: Access modifiers like public, private, and protected control the visibility and accessibility of class members to ensure proper encapsulation.