0% found this document useful (0 votes)
25 views4 pages

Understanding Objects and Classes

Chapter 2 of the GoodWill Educational Content provides a series of questions and answers related to object-oriented programming concepts, including definitions of objects, classes, methods, and constructors. It also covers method overloading and overriding, as well as access modifiers such as private and protected. The content is presented in both English and Urdu for better understanding.

Uploaded by

shahmeerjabbar66
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)
25 views4 pages

Understanding Objects and Classes

Chapter 2 of the GoodWill Educational Content provides a series of questions and answers related to object-oriented programming concepts, including definitions of objects, classes, methods, and constructors. It also covers method overloading and overriding, as well as access modifiers such as private and protected. The content is presented in both English and Urdu for better understanding.

Uploaded by

shahmeerjabbar66
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

GoodWill Educational Content | Chapter: chapter2

chapter2
Questions & Answers

Q1. What is an object?


Answer (English): An instance of a class that has state and behavior.

:(‫ﺟﻮﺍﺏ )ﺍﺭﺩﻭ‬

‫ﺍﯾﮏ ﮐﻼﺱ ﮐﺎ ﺍﯾﮏ ﺍﯾﺴﺎ ﻧﻤﻮﻧﮧ ﺟﻮ ﺣﺎﻟﺖ ﺍﻭﺭ ﺭﻭﯾﮧ ﺭﮐﮭﺘﺎ ﮨﮯ۔‬

Q2. Create an object.


Answer (English): Example: ClassName obj = new ClassName();

:(‫ﺟﻮﺍﺏ )ﺍﺭﺩﻭ‬

;()ClassName obj = new ClassName :‫ﻣﺜﺎﻝ‬

Q3. What is class?


Answer (English): A blueprint for creating objects, defining properties and methods.

:(‫ﺟﻮﺍﺏ )ﺍﺭﺩﻭ‬

‫ ﺧﺼﻮﺻﯿﺎﺕ ﺍﻭﺭ ﻃﺮﯾﻘﮯ ﻣﺘﻌﯿﻦ ﮐﺮﺗﺎ ﮨﮯ۔‬،‫ﺍﺷﯿﺎﺀ ﺑﻨﺎﻧﮯ ﮐﮯ ﻟﯿﮯ ﺍﯾﮏ ﺧﺎﮐﮧ‬

Q4. Create a class?


Answer (English): Example: class ClassName { }

:(‫ﺟﻮﺍﺏ )ﺍﺭﺩﻭ‬

{ } class ClassName :‫ﻣﺜﺎﻝ‬

Q5. What is a method?


Answer (English): A block of code that performs a specific task.
:(‫ﺟﻮﺍﺏ )ﺍﺭﺩﻭ‬

‫ﮐﻮﮈ ﮐﺎ ﺍﯾﮏ ﺑﻼﮎ ﺟﻮ ﺍﯾﮏ ﻣﺨﺼﻮﺹ ﮐﺎﻡ ﺍﻧﺠﺎﻡ ﺩﯾﺘﺎ ﮨﮯ۔‬

Q6. Create a method?


Answer (English): Example: void methodName() { }

:(‫ﺟﻮﺍﺏ )ﺍﺭﺩﻭ‬

{ } ()void methodName :‫ﻣﺜﺎﻝ‬

Q7. Define Method Overloading?


Answer (English): Defining multiple methods with the same name but different
parameters.

:(‫ﺟﻮﺍﺏ )ﺍﺭﺩﻭ‬

‫ﺍﯾﮏ ﮨﯽ ﻧﺎﻡ ﮐﮯ ﺳﺎﺗﮫ ﻣﺨﺘﻠﻒ ﭘﯿﺮﺍﻣﯿﭩﺮﺯ ﮐﮯ ﺳﺎﺗﮫ ﻣﺘﻌﺪﺩ ﻃﺮﯾﻘﮯ ﻣﺘﻌﯿﻦ ﮐﺮﻧﺎ۔‬

Q8. Write Method Overloading Benefits?


Answer (English): Improves code readability and allows methods to perform similar
functions.

:(‫ﺟﻮﺍﺏ )ﺍﺭﺩﻭ‬

‫ﭘﮍﮬﻨﮯ ﮐﯽ ﺻﻼﺣﯿﺖ ﮐﻮ ﺑﮩﺘﺮ ﺑﻨﺎﺗﺎ ﮨﮯ ﺍﻭﺭ ﻃﺮﯾﻘﻮﮞ ﮐﻮ ﻣﺸﺎﺑﮧ ﺍﻓﻌﺎﻝ ﺍﻧﺠﺎﻡ ﺩﯾﻨﮯ ﮐﯽ ﺍﺟﺎﺯﺕ ﺩﯾﺘﺎ ﮨﮯ۔‬
‫ﮐﻮﮈ ﮐﯽ‬

Q9. Write Uses of Method Overriding?


Answer (English): To provide specific implementation of a method in a subclass.

:(‫ﺟﻮﺍﺏ )ﺍﺭﺩﻭ‬

‫ﺍﯾﮏ ﺫﯾﻠﯽ ﮐﻼﺱ ﻣﯿﮟ ﺍﯾﮏ ﻃﺮﯾﻘﮯ ﮐﺎ ﻣﺨﺼﻮﺹ ﻧﻔﺎﺫ ﻓﺮﺍﮨﻢ ﮐﺮﻧﮯ ﮐﮯ ﻟﯿﮯ۔‬

Q10. Define Constructor?


Answer (English): A special method used to initialize objects.

:(‫ﺟﻮﺍﺏ )ﺍﺭﺩﻭ‬
‫ﺍﯾﮏ ﺧﺎﺹ ﻃﺮﯾﻘﮧ ﺟﻮ ﺍﺷﯿﺎﺀ ﮐﻮ ﺍﺑﺘﺪﺍﺋﯽ ﺷﮑﻞ ﺩﯾﻨﮯ ﮐﮯ ﻟﯿﮯ ﺍﺳﺘﻌﻤﺎﻝ ﮨﻮﺗﺎ ﮨﮯ۔‬

Q11. Define access modifiers?


Answer (English): Keywords that set the accessibility of classes, methods, and
variables.

:(‫ﺟﻮﺍﺏ )ﺍﺭﺩﻭ‬

‫ ﺍﻭﺭ ﻣﺘﻐﯿﺮﺍﺕ ﮐﯽ ﺭﺳﺎﺋﯽ ﮐﻮ ﻣﺘﻌﯿﻦ ﮐﺮﺗﮯ ﮨﯿﮟ۔‬،‫ ﻃﺮﯾﻘﻮﮞ‬،‫ﮐﯽ ﻭﺭﮈﺯ ﺟﻮ ﮐﻼﺳﺰ‬

Q12. Define Private Access Modifier?


Answer (English): Restricts access to the class itself.

:(‫ﺟﻮﺍﺏ )ﺍﺭﺩﻭ‬

‫ﮐﻼﺱ ﺗﮏ ﺭﺳﺎﺋﯽ ﮐﻮ ﻣﺤﺪﻭﺩ ﮐﺮﺗﺎ ﮨﮯ۔‬

Q13. Define Protected Access Modifier?


Answer (English): Allows access to the class itself and subclasses.

:(‫ﺟﻮﺍﺏ )ﺍﺭﺩﻭ‬

‫ﮐﻼﺱ ﺍﻭﺭ ﺫﯾﻠﯽ ﮐﻼﺳﺰ ﺗﮏ ﺭﺳﺎﺋﯽ ﮐﯽ ﺍﺟﺎﺯﺕ ﺩﯾﺘﺎ ﮨﮯ۔‬

Q14. What is default constructor?


Answer (English): A constructor that does not take any parameters.

:(‫ﺟﻮﺍﺏ )ﺍﺭﺩﻭ‬

‫ﺍﯾﮏ ﮐﻨﺴﭩﺮﮐﭩﺮ ﺟﻮ ﮐﻮﺋﯽ ﭘﯿﺮﺍﻣﯿﭩﺮ ﻧﮩﯿﮟ ﻟﯿﺘﺎ۔‬

Q15. What are Parameterized Constructors?


Answer (English): Constructors that take parameters to initialize object attributes.

:(‫ﺟﻮﺍﺏ )ﺍﺭﺩﻭ‬

‫ﮐﻨﺴﭩﺮﮐﭩﺮ ﺟﻮ ﺍﺷﯿﺎﺀ ﮐﯽ ﺧﺼﻮﺻﯿﺎﺕ ﮐﻮ ﺍﺑﺘﺪﺍﺋﯽ ﺷﮑﻞ ﺩﯾﻨﮯ ﮐﮯ ﻟﯿﮯ ﭘﯿﺮﺍﻣﯿﭩﺮﺯ ﻟﯿﺘﮯ ﮨﯿﮟ۔‬
Generated by GoodWill Notes Maker
Educational content for exam preparation
Study well, succeed better!

You might also like