Chapter 3 - Elementary Concepts of Objects and Classes: Ryan International School, Kharghar Computer Applications STD: Ix
Chapter 3 - Elementary Concepts of Objects and Classes: Ryan International School, Kharghar Computer Applications STD: Ix
Chapter 3 - Elementary Concepts of Objects and Classes: Ryan International School, Kharghar Computer Applications STD: Ix
COMPUTER APPLICATIONS
STD: IX
CHAPTER 3 – ELEMENTARY CONCEPTS OF OBJECTS AND CLASSES
DATE: 18/06/2021
NOTES:
12) Write a program snippet to print “Hello World” on the screen. Which
type of method does it use?
ANS:
class Example
{
public static void main(String args [ ])
{
System.out.println(“Hello World”);
}
}
It uses static method.
13) Write program snippet to show the differences between static and
instance methods.
ANS:
Static Method:
class Example
{
public static void main(String args [ ])
{
System.out.println(“Hello World”);
}
}
Instance Method:
class PRG
{
void display() // instance method
{
//statements ;
}
public static void main(String args[ ])
{
PRG obj = new PRG() ;
obj.display();
}
}
14) A class is called an object factory. Explain with the help of an example.
ANS:
Each class describes possibly an infinite set of individual objects. So, it can be
called as a factory of objects. For example, a class of cellphone can have
numerous objects as Nokia, Samsung, Panasonic, etc. The features and functions
of the objects are described within the class.
class Example
{
void display()
{
System.out.println(“Hello World”);
}
Prepared by:
Mrs. Bhashwini Mittal