[go: up one dir, main page]

0% found this document useful (0 votes)
12 views5 pages

Short Answer Type Questions: Ryan International School, Nashik 3: Elementry Concepts of Objects and Classes STD Ix

The document provides a series of short answer questions and answers related to elementary concepts of objects and classes in programming, specifically for a 9th-grade curriculum. Key topics include the definition of instance variables, methods, classes, and the differences between static and instance methods. It also includes examples of code snippets to illustrate these concepts.

Uploaded by

tengentonop
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views5 pages

Short Answer Type Questions: Ryan International School, Nashik 3: Elementry Concepts of Objects and Classes STD Ix

The document provides a series of short answer questions and answers related to elementary concepts of objects and classes in programming, specifically for a 9th-grade curriculum. Key topics include the definition of instance variables, methods, classes, and the differences between static and instance methods. It also includes examples of code snippets to illustrate these concepts.

Uploaded by

tengentonop
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

RYAN INTERNATIONAL SCHOOL, NASHIK

3 : ELEMENTRY CONCEPTS OF OBJECTS AND CLASSES

STD IX

Short answer type questions


1. Give reasons why we model real world entities and their behavior.
Ans
1. a model is a simplification of reality. We model because we cannot
comprehend the complexity of a system in its entirety
2. We mmodel to visualize, specify, construct and document the structure
and behavior of a system’s architecture.

2. What are instance variables?


Ans : Variables which are declared as non static are instance variables.
These variables are to indicate the current state of an object. Instance
variables are declared in the class, outside the method.

3. With the help of an example explain what is a message in a software


application?
Ans : Software objects interact or communicate with each other using
messages.
public class add
{
public void addition(int a, int b)
{
System.out.println(”Addition is : “+(a+b));
}
public static void main()
{
add obj=new add();
obj.addition(7,8);
}
}
Formal parameters are the variables a and b, as we call the method we pass
the values 7 and 8 these are the messages sent by object to the method
addition.
4. What is the difference between a class and object?
Ans :
class object
Class is a blueprint or prototype , Objects are the instances of the class
that defines the variables and the
methods common to all objects of a
certain kind
A class is an abstract type. It do not Objects are entities that actually
exist in computer memory exists in computer memory
Only 1 class is created In one class we can create as many
objects as we want

5. Name the main parts of a class.


Ans : 1. Attributes or fields or member variables.
2 Constructor
3 functions
6. How is a class a user defined datatype?
Ans : A class is made up of many variables of different data types so it is
called user defined datatype. Example In student class we can have
rollnumber of int type, name of String datatype, percentage of double
datatype.

7. What is a method? List two types of methods?


Ans : Method is a subprogram that acts on data and often returns a value.
Two types of methods are
1. Pre-defined method
2. User Defined Method.

8. What are predefined methods? Give an example.


Ans : Predefined methods are readymade methods provided by java, they
are created by developers of java.
Math.sqrt(25) , Math.cbrt(8), these are predefined methods of Math class
System.out.print(“Hello”); print method for printing quoted string.

9. What do you understand by static method? Give an example.


Ans :A method written using static keyword and it is called without creating
an object, is called static method.
public class program
{
public static void main()
{
System.out.println(“Hello World”);
}
}
10.Which methods can be overridden? Name the principle of OOP that
supports this feature.
Ans : Methods with same name and different parameters written in one
class, are overwritten.
Polymorphism is the OOP that supports this feature.

11.Write a program snippet to print “Hello World “ on screen. Which type of


method does it use?
Ans : public class program
{
public static void main()
{
System.out.println(“Hello World”);
}
}
Write a program snippet to show the difference between static and instance
method
public class add
{
public void addition(int a, int b)
{
System.out.println(“Addition”+(a+b));
}
public static void main()
{
add obj=new add(); //(This creating an object)
add obj1=new add();
add obj2=new add();
add obj3=new add();
obj.addition(12,25); //4 objects created and methods called
obj1.addition(1326,25);
obj2.addition(162,275);
obj3.addition(1232,2785);

14 A class is called an object factory. Explain with the help of an example.


Ans
We can create as many object as we want inside one single class, so class is
called an object factory.
public class add
{
public void addition(int a, int b)
{
System.out.println(“Addition”+(a+b));
}
public static void main()
{
add obj=new add(); //(This creating an object)
add obj1=new add();
add obj2=new add();
add obj3=new add();
obj.addition(12,25); //4 objects created and methods called
obj1.addition(1326,25);
obj2.addition(162,275);
obj3.addition(1232,2785);

}
--------------------------------------------

You might also like