SlideShare a Scribd company logo
https://www.facebook. com/Oxus20

PART I – Scenario to program and code :
1. Write a method that accept a String named "strInput" as a parameter and returns
every other character of that String parameter starting with the first character.

M e t ho d I: - Us in g L o op
public static String everyOther(String strInput) {
String output = "";
for (int index = 0; index < strInput.length(); index += 2) {
output += strInput.charAt(index);
}
return output;
}

Tips:
 Each and every characters of the given String parameter needs to be scanned and

processed. Therefore, we need to know the number of characters in the String.
strInput.length();
st

1

character is needed that is why int index = 0; we don't need the 2

nd

character that

is why we incremented index by 2 as follow: index += 2
 strInput.charAt(index); reading the actual character and concatenated to the output

variable.
 Finally

System.out.println( everyOther("SshHeErRzZaAdD") ); // will print Sherzad

M e t ho d I I :- Us in g R e g u la r E xp r es s ion
public static String everyOther(String strInput) {
return strInput.replaceAll("(.)(.)", "$1");
}

Tips:
 In Regular Expression

. matches any character

 In Regular Expression

() use for grouping

 strInput.replaceAll("(.)(.)",

"$1"); // in the expression (.)(.), there are

two groups and each group matches any character; then, in the replacement string,
we can refer to the text of group 1 with the expression $1. Therefore, every other
character will be returned as follow:
System.out.println( everyOther("SshHeErRzZaAdD") ); // will print Sherzad

Abdul Rahman Sherzad

Page 1 of 5
https://www.facebook. com/Oxus20

2. Write a method named reverseString that accepts a String parameter and returns the
reverse of the given String parameter.

M e t ho d I: - Us in g Lo op
public static String reverseString(String strInput) {
String output = "";
for (int index = (strInput.length() - 1); index >= 0; index--) {
output += strInput.charAt(index);
}
return output;
}

Tips:
 Each and every characters of the given String parameter needs to be scanned and

processed. Therefore, we need to know the number of characters in the String.
strInput.length();
 Since index ranges from 0 to strInput.length() - 1; that is why we read each and every

character from the end int index = (strInput.length() - 1);
 Finally System.out.println( reverseString("02SUXO") ); // will print OXUS20

M e t ho d I I :- Us in g r e ve rs e ( ) m e t ho d o f S t ri n g B u i ld e r / S t r in g Bu f f e r c la s s
public static String reverseString(String strInput) {
if ((strInput == null) || (strInput.length() <= 1)) {
return strInput;
}
return new StringBuffer(strInput).reverse().toString();
}

Tips:
 Both StringBuilder and StringBuffer class have a reverse method. They work pretty much

the same, except that methods in StringBuilder are not synchronized.

M e t ho d I I I:- Us in g s ubs t r in g ( ) a n d Re c u rs i o n
public static String reverseString(String strInput) {
if ( strInput.equals("") )
return "";
return reverseString(strInput.substring(1)) + strInput.substring(0, 1);
}
public String substring(int beginIndex)
public String substring(int beginIndex, int endIndex)

Abdul Rahman Sherzad

Page 2 of 5
https://www.facebook. com/Oxus20

3. Write a method to generate a random number in a specific range. For instance, if
the given range is 15 - 25, meaning that 15 is the smallest possible value the
random number can take, and 25 is the biggest. Any other number in between these
numbers is possible to be a value, too.

M e t ho d I: - Us in g R a nd om c la s s o f ja va .u t il p a c ka g e
public static int rangeInt(int min, int max) {
java.util.Random rand = new java.util.Random();
int randomOutput = rand.nextInt((max - min) + 1) + min;
return randomOutput;
}

Tips:
 The nextInt(int n) method is used to get an int value between 0 (inclusive) and the

specified value (exclusive).
 Consider min = 15, max = 25, then

o rand.nextInt(max - min) // return a random int between 0 (inclusive) and 10
(exclusive). Interval demonstration [0, 10)
o rand.nextInt((max - min) + 1) // return a random int 0 and 10 both inclusive
o rand.nextInt((max

- min) + 1) + min // return a random int 0 and 10

both inclusive + 15;


if the return random int is 0 then 0 + 15 will be 15;



if the return random int is 10 then 10 + 15 will be 25;



if the return random int is 5 then 5 + 15 will be 20;



Hence the return random int will be between min and max value both
inclusive.

M e t ho d I I :- Us in g M a t h .r a nd om ( ) m e th o d
public static int rangeInt(int min, int max) {
return (int) ( Math.random() * ( (max – min) + 1 ) ) + min;
}

Note:
 In practice, the Random class is often preferable

to Math.random().

Abdul Rahman Sherzad

Page 3 of 5
https://www.facebook. com/Oxus20

PART II – Single Choice and Multiple Choices:
1. Which of the following declarations is correct?

 [A ] boolean b = TRUE;
 [B] byte b = 255;

[A] boolean b = TRUE; // JAVA is Case Sensitive!

 [C] String s = "null";

[B] byte b = 255; // Out of range MIN_VALUE = -128 and
MAX_VALUE = 127

 [D] int i = new Integer("56");

[C] String s = "null"; // Everything between double quotes ""
considered as String
[D] int i = new Integer("56"); // The string "56" is converted
to an int value.

2. Consider the following program:
import oxus20Library.*;
public class OXUS20 {
public static void main(String[] args) {
// The code goes here ...
}
}

What is the name of the java file containing this program?
 A. oxus20Library.java
 B. OXUS20.java

 Each JAVA source file can contain only one
public class.

 C. OXUS20

 The source file's name has to be the name of
that public class. By convention, the

 D. OXUS20.class

source file uses a .java filename extension

 E. Any file name w ith the java suffix is accepted

3. Consider the following code snippet
public class OXUS20 {
public static void main(String[] args) {
String river = new String("OXUS means Amu Darya");
System.out.println(river.length());
}
}

What is printed?
 A. 17

 B. OXUS means Amu Darya

Abdul Rahman Sherzad

 C. 20

 E. river

Page 4 of 5
https://www.facebook. com/Oxus20

4. A constructor

 A. mus t have the same name as the class it is declared w ithin.
 B. is used to create objects.
 C. may be declared private
 D. A ll the above

 A.

A c o n s t r u c t o r m u s t h a ve t h e s a m e n a m e a s t h e c l a s s i t i s d e c l a r e d w i t h i n .
public class OXUS20 {
public OXUS20() {
}
}

 B.

C o n s t ru c t o r i s u s e d t o c re a te o b j e c ts
OXUS20 amu_darya = new OXUS20();

 C.

C o n s t ru c t o r m a y b e d e c l a r e d p r i va t e // private constructor is off
course to restrict instantiation of the class. Actually a good
use of private constructor is in Singleton Pattern.

5. Which of the following may be part of a class definition?

 A. instance variables
 B. instance methods
Following is a sample of class declaration:

 C. constructors
 D. All of the above

class MyClass {
 Field // class variables or instance variables

 E. None of the above
 constructor, and // class constructor or overloaded constructors

 method declarations // class methods or instance methods

}

Abdul Rahman Sherzad

Page 5 of 5
‫‪OXUS20 is a non-profit society with the aim of changing education for the better‬‬
‫.‪by providing education and assistance to IT and computer science professionals‬‬

‫آکسیوس20 یک انجمن غیر انتفاعی با هدف تغییرو تقویت آموزش و پرورش از طریق ارائه آموزش و کمک به متخصصان علوم‬
‫کامپیوتر است.‬
‫نام این انجمن برگرفته از دریای آمو پر آب ترین رود آسیای میانه که دست موج آن بیانگر استعداد های نهفته این انجمن بوده، و این دریا از دامنه های کهن پامیر‬
‫سرچشمه گرفته و ماورای شمالی سرزمین باستانی افغانستان را آبیاری میکند که این حالت دریا هدف ارایه خدمات انجمن را انعکاس میدهد.‬
‫آکسیوس20 در نظر دارد تا خدماتی مانند ایجاد فضای مناسب برای تجلی استعدادها و برانگیختن خالقیت و شکوفایی علمی محصالن و دانش پژوهان، نهادمند‬
‫ساختن فعالیت های فوق برنامه علمی و کاربردی، شناسایی افراد خالق، نخبه و عالقمند و بهره گیری از مشارکت آنها در ارتقای فضای علمی پوهنتون ها و دیگر‬
‫مراکز آموزشی و جامعه همچون تولید و انتشار نشریات علمی تخصصی علوم عصری و تکنالوژی معلوماتی را به شکل موثر آن در جامعه در راستای هرچه بهتر‬
‫شدن زمینه تدریس، تحقیق و پژوهش و راه های رسیدن به آمال افراد جامعه را فراهم میسازد.‬

‫,‪Follow us on Facebook‬‬
‫02‪https://www.facebook.com/Oxus‬‬

More Related Content

PPS
T02 a firstcprogram
PDF
C language sample test
PPT
Lecture 15 - Array
PDF
Hash tables
PDF
2. Базовый синтаксис Java
PPT
Lecture 17 - Strings
T02 a firstcprogram
C language sample test
Lecture 15 - Array
Hash tables
2. Базовый синтаксис Java
Lecture 17 - Strings

What's hot (17)

PDF
OpenGL ES 3 Reference Card
PPT
Lecture 16 - Multi dimensional Array
PDF
2 data and c
PDF
03 structures
DOCX
C cheat sheet for varsity (extreme edition)
PDF
Cse115 lecture14strings part01
PDF
Class 2: Welcome part 2
PPTX
C# overview part 1
PPT
PDF
Keygenning using the Z3 SMT Solver
PPTX
Memory management of datatypes
PDF
OO-like C Programming: Struct Inheritance and Virtual Function
PPSX
Programming in C [Module One]
PDF
Class 5: If, while & lists
PPTX
Module 5-Structure and Union
PDF
VIT351 Software Development VI Unit2
OpenGL ES 3 Reference Card
Lecture 16 - Multi dimensional Array
2 data and c
03 structures
C cheat sheet for varsity (extreme edition)
Cse115 lecture14strings part01
Class 2: Welcome part 2
C# overview part 1
Keygenning using the Z3 SMT Solver
Memory management of datatypes
OO-like C Programming: Struct Inheritance and Virtual Function
Programming in C [Module One]
Class 5: If, while & lists
Module 5-Structure and Union
VIT351 Software Development VI Unit2
Ad

Viewers also liked (20)

PDF
java question paper 5th sem
PDF
Java (Information Technology) Question paper for T.Y Bca
PDF
Java Programming Question paper Aurangabad MMS
PDF
5th Semester (December; January-2014 and 2015) Computer Science and Informati...
DOCX
Java mcq
PDF
Java programming-examples
PDF
Java Tuning White Paper
PDF
5th semester VTU BE CS & IS question papers from 2010 to July 2016
PDF
5th semester Computer Science and Information Science Engg (2013 December) Qu...
PDF
Java apptitude-questions-part-2
PDF
Java Multiple Choice Questions and Answers
PPSX
Core java lessons
PDF
Java apptitude-questions-part-1
PPTX
TKP Java Notes for Teaching Kids Programming
PDF
Java Regular Expression PART I
PDF
Everything about Object Oriented Programming
PPTX
Conditional Statement
PDF
Java Virtual Keyboard Using Robot, Toolkit and JToggleButton Classes
PDF
Java Unicode with Cool GUI Examples
PDF
PHP Basic and Fundamental Questions and Answers with Detail Explanation
java question paper 5th sem
Java (Information Technology) Question paper for T.Y Bca
Java Programming Question paper Aurangabad MMS
5th Semester (December; January-2014 and 2015) Computer Science and Informati...
Java mcq
Java programming-examples
Java Tuning White Paper
5th semester VTU BE CS & IS question papers from 2010 to July 2016
5th semester Computer Science and Information Science Engg (2013 December) Qu...
Java apptitude-questions-part-2
Java Multiple Choice Questions and Answers
Core java lessons
Java apptitude-questions-part-1
TKP Java Notes for Teaching Kids Programming
Java Regular Expression PART I
Everything about Object Oriented Programming
Conditional Statement
Java Virtual Keyboard Using Robot, Toolkit and JToggleButton Classes
Java Unicode with Cool GUI Examples
PHP Basic and Fundamental Questions and Answers with Detail Explanation
Ad

Similar to JAVA Programming Questions and Answers PART III (20)

PPT
CSC128_Part_1_WrapperClassesAndStrings_CenBNcj.ppt
PDF
OXUS20 JAVA Programming Questions and Answers PART I
PPTX
ch 4 mathematical function character and string.pptx
PDF
Chapter 3
PPT
Eo gaddis java_chapter_08_5e
PPT
Eo gaddis java_chapter_08_5e
PDF
java-programming.pdf
PPSX
Java String class
PPTX
04slide Update.pptx
PPT
Java căn bản - Chapter9
PDF
Airoli_Grade 10_CompApp_PP000000000000000000000000000000000000000000T_Charact...
PPT
Chapter 9 - Characters and Strings
PPT
Cso gaddis java_chapter10
PDF
vision_academy_classes_Bcs_bca_bba_java part_2 (1).pdf
PDF
Vision academy classes_bcs_bca_bba_java part_2
PDF
java.lang.String Class
PDF
Lec 8 03_sept [compatibility mode]
PPTX
String.pptxihugyftgrfxdf bnjklihugyfthfgxvhbjihugyfthcgxcgvjhbkipoihougyfctgf...
PPT
LiangChapter4 Unicode , ASCII Code .ppt
PPTX
Ifi7184 lesson3
CSC128_Part_1_WrapperClassesAndStrings_CenBNcj.ppt
OXUS20 JAVA Programming Questions and Answers PART I
ch 4 mathematical function character and string.pptx
Chapter 3
Eo gaddis java_chapter_08_5e
Eo gaddis java_chapter_08_5e
java-programming.pdf
Java String class
04slide Update.pptx
Java căn bản - Chapter9
Airoli_Grade 10_CompApp_PP000000000000000000000000000000000000000000T_Charact...
Chapter 9 - Characters and Strings
Cso gaddis java_chapter10
vision_academy_classes_Bcs_bca_bba_java part_2 (1).pdf
Vision academy classes_bcs_bca_bba_java part_2
java.lang.String Class
Lec 8 03_sept [compatibility mode]
String.pptxihugyftgrfxdf bnjklihugyfthfgxvhbjihugyfthcgxcgvjhbkipoihougyfctgf...
LiangChapter4 Unicode , ASCII Code .ppt
Ifi7184 lesson3

More from OXUS 20 (16)

PDF
Java Arrays
PPTX
Java Methods
PPTX
Structure programming – Java Programming – Theory
PDF
Java Applet and Graphics
PDF
Fundamentals of Database Systems Questions and Answers
PDF
Everything about Database JOINS and Relationships
PDF
Create Splash Screen with Java Step by Step
PDF
Fal-e-Hafez (Omens of Hafez) Cards in Persian using Java
PDF
Web Design and Development Life Cycle and Technologies
PDF
JAVA GUI PART III
PDF
Java Regular Expression PART II
PDF
Java GUI PART II
PDF
JAVA GUI PART I
PDF
Java Guessing Game Number Tutorial
PDF
Object Oriented Programming with Real World Examples
PDF
Object Oriented Concept Static vs. Non Static
Java Arrays
Java Methods
Structure programming – Java Programming – Theory
Java Applet and Graphics
Fundamentals of Database Systems Questions and Answers
Everything about Database JOINS and Relationships
Create Splash Screen with Java Step by Step
Fal-e-Hafez (Omens of Hafez) Cards in Persian using Java
Web Design and Development Life Cycle and Technologies
JAVA GUI PART III
Java Regular Expression PART II
Java GUI PART II
JAVA GUI PART I
Java Guessing Game Number Tutorial
Object Oriented Programming with Real World Examples
Object Oriented Concept Static vs. Non Static

Recently uploaded (20)

PPTX
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PPTX
Lesson notes of climatology university.
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
01-Introduction-to-Information-Management.pdf
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
Complications of Minimal Access Surgery at WLH
PPTX
GDM (1) (1).pptx small presentation for students
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PPTX
Presentation on HIE in infants and its manifestations
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
PDF
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
PPTX
202450812 BayCHI UCSC-SV 20250812 v17.pptx
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PPTX
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
PPTX
Pharma ospi slides which help in ospi learning
PDF
Microbial disease of the cardiovascular and lymphatic systems
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
O7-L3 Supply Chain Operations - ICLT Program
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
Lesson notes of climatology university.
Final Presentation General Medicine 03-08-2024.pptx
01-Introduction-to-Information-Management.pdf
VCE English Exam - Section C Student Revision Booklet
Complications of Minimal Access Surgery at WLH
GDM (1) (1).pptx small presentation for students
human mycosis Human fungal infections are called human mycosis..pptx
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Presentation on HIE in infants and its manifestations
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
202450812 BayCHI UCSC-SV 20250812 v17.pptx
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
Pharma ospi slides which help in ospi learning
Microbial disease of the cardiovascular and lymphatic systems

JAVA Programming Questions and Answers PART III

  • 1. https://www.facebook. com/Oxus20 PART I – Scenario to program and code : 1. Write a method that accept a String named "strInput" as a parameter and returns every other character of that String parameter starting with the first character. M e t ho d I: - Us in g L o op public static String everyOther(String strInput) { String output = ""; for (int index = 0; index < strInput.length(); index += 2) { output += strInput.charAt(index); } return output; } Tips:  Each and every characters of the given String parameter needs to be scanned and processed. Therefore, we need to know the number of characters in the String. strInput.length(); st 1 character is needed that is why int index = 0; we don't need the 2 nd character that is why we incremented index by 2 as follow: index += 2  strInput.charAt(index); reading the actual character and concatenated to the output variable.  Finally System.out.println( everyOther("SshHeErRzZaAdD") ); // will print Sherzad M e t ho d I I :- Us in g R e g u la r E xp r es s ion public static String everyOther(String strInput) { return strInput.replaceAll("(.)(.)", "$1"); } Tips:  In Regular Expression . matches any character  In Regular Expression () use for grouping  strInput.replaceAll("(.)(.)", "$1"); // in the expression (.)(.), there are two groups and each group matches any character; then, in the replacement string, we can refer to the text of group 1 with the expression $1. Therefore, every other character will be returned as follow: System.out.println( everyOther("SshHeErRzZaAdD") ); // will print Sherzad Abdul Rahman Sherzad Page 1 of 5
  • 2. https://www.facebook. com/Oxus20 2. Write a method named reverseString that accepts a String parameter and returns the reverse of the given String parameter. M e t ho d I: - Us in g Lo op public static String reverseString(String strInput) { String output = ""; for (int index = (strInput.length() - 1); index >= 0; index--) { output += strInput.charAt(index); } return output; } Tips:  Each and every characters of the given String parameter needs to be scanned and processed. Therefore, we need to know the number of characters in the String. strInput.length();  Since index ranges from 0 to strInput.length() - 1; that is why we read each and every character from the end int index = (strInput.length() - 1);  Finally System.out.println( reverseString("02SUXO") ); // will print OXUS20 M e t ho d I I :- Us in g r e ve rs e ( ) m e t ho d o f S t ri n g B u i ld e r / S t r in g Bu f f e r c la s s public static String reverseString(String strInput) { if ((strInput == null) || (strInput.length() <= 1)) { return strInput; } return new StringBuffer(strInput).reverse().toString(); } Tips:  Both StringBuilder and StringBuffer class have a reverse method. They work pretty much the same, except that methods in StringBuilder are not synchronized. M e t ho d I I I:- Us in g s ubs t r in g ( ) a n d Re c u rs i o n public static String reverseString(String strInput) { if ( strInput.equals("") ) return ""; return reverseString(strInput.substring(1)) + strInput.substring(0, 1); } public String substring(int beginIndex) public String substring(int beginIndex, int endIndex) Abdul Rahman Sherzad Page 2 of 5
  • 3. https://www.facebook. com/Oxus20 3. Write a method to generate a random number in a specific range. For instance, if the given range is 15 - 25, meaning that 15 is the smallest possible value the random number can take, and 25 is the biggest. Any other number in between these numbers is possible to be a value, too. M e t ho d I: - Us in g R a nd om c la s s o f ja va .u t il p a c ka g e public static int rangeInt(int min, int max) { java.util.Random rand = new java.util.Random(); int randomOutput = rand.nextInt((max - min) + 1) + min; return randomOutput; } Tips:  The nextInt(int n) method is used to get an int value between 0 (inclusive) and the specified value (exclusive).  Consider min = 15, max = 25, then o rand.nextInt(max - min) // return a random int between 0 (inclusive) and 10 (exclusive). Interval demonstration [0, 10) o rand.nextInt((max - min) + 1) // return a random int 0 and 10 both inclusive o rand.nextInt((max - min) + 1) + min // return a random int 0 and 10 both inclusive + 15;  if the return random int is 0 then 0 + 15 will be 15;  if the return random int is 10 then 10 + 15 will be 25;  if the return random int is 5 then 5 + 15 will be 20;  Hence the return random int will be between min and max value both inclusive. M e t ho d I I :- Us in g M a t h .r a nd om ( ) m e th o d public static int rangeInt(int min, int max) { return (int) ( Math.random() * ( (max – min) + 1 ) ) + min; } Note:  In practice, the Random class is often preferable to Math.random(). Abdul Rahman Sherzad Page 3 of 5
  • 4. https://www.facebook. com/Oxus20 PART II – Single Choice and Multiple Choices: 1. Which of the following declarations is correct?  [A ] boolean b = TRUE;  [B] byte b = 255; [A] boolean b = TRUE; // JAVA is Case Sensitive!  [C] String s = "null"; [B] byte b = 255; // Out of range MIN_VALUE = -128 and MAX_VALUE = 127  [D] int i = new Integer("56"); [C] String s = "null"; // Everything between double quotes "" considered as String [D] int i = new Integer("56"); // The string "56" is converted to an int value. 2. Consider the following program: import oxus20Library.*; public class OXUS20 { public static void main(String[] args) { // The code goes here ... } } What is the name of the java file containing this program?  A. oxus20Library.java  B. OXUS20.java  Each JAVA source file can contain only one public class.  C. OXUS20  The source file's name has to be the name of that public class. By convention, the  D. OXUS20.class source file uses a .java filename extension  E. Any file name w ith the java suffix is accepted 3. Consider the following code snippet public class OXUS20 { public static void main(String[] args) { String river = new String("OXUS means Amu Darya"); System.out.println(river.length()); } } What is printed?  A. 17  B. OXUS means Amu Darya Abdul Rahman Sherzad  C. 20  E. river Page 4 of 5
  • 5. https://www.facebook. com/Oxus20 4. A constructor  A. mus t have the same name as the class it is declared w ithin.  B. is used to create objects.  C. may be declared private  D. A ll the above  A. A c o n s t r u c t o r m u s t h a ve t h e s a m e n a m e a s t h e c l a s s i t i s d e c l a r e d w i t h i n . public class OXUS20 { public OXUS20() { } }  B. C o n s t ru c t o r i s u s e d t o c re a te o b j e c ts OXUS20 amu_darya = new OXUS20();  C. C o n s t ru c t o r m a y b e d e c l a r e d p r i va t e // private constructor is off course to restrict instantiation of the class. Actually a good use of private constructor is in Singleton Pattern. 5. Which of the following may be part of a class definition?  A. instance variables  B. instance methods Following is a sample of class declaration:  C. constructors  D. All of the above class MyClass {  Field // class variables or instance variables  E. None of the above  constructor, and // class constructor or overloaded constructors  method declarations // class methods or instance methods } Abdul Rahman Sherzad Page 5 of 5
  • 6. ‫‪OXUS20 is a non-profit society with the aim of changing education for the better‬‬ ‫.‪by providing education and assistance to IT and computer science professionals‬‬ ‫آکسیوس20 یک انجمن غیر انتفاعی با هدف تغییرو تقویت آموزش و پرورش از طریق ارائه آموزش و کمک به متخصصان علوم‬ ‫کامپیوتر است.‬ ‫نام این انجمن برگرفته از دریای آمو پر آب ترین رود آسیای میانه که دست موج آن بیانگر استعداد های نهفته این انجمن بوده، و این دریا از دامنه های کهن پامیر‬ ‫سرچشمه گرفته و ماورای شمالی سرزمین باستانی افغانستان را آبیاری میکند که این حالت دریا هدف ارایه خدمات انجمن را انعکاس میدهد.‬ ‫آکسیوس20 در نظر دارد تا خدماتی مانند ایجاد فضای مناسب برای تجلی استعدادها و برانگیختن خالقیت و شکوفایی علمی محصالن و دانش پژوهان، نهادمند‬ ‫ساختن فعالیت های فوق برنامه علمی و کاربردی، شناسایی افراد خالق، نخبه و عالقمند و بهره گیری از مشارکت آنها در ارتقای فضای علمی پوهنتون ها و دیگر‬ ‫مراکز آموزشی و جامعه همچون تولید و انتشار نشریات علمی تخصصی علوم عصری و تکنالوژی معلوماتی را به شکل موثر آن در جامعه در راستای هرچه بهتر‬ ‫شدن زمینه تدریس، تحقیق و پژوهش و راه های رسیدن به آمال افراد جامعه را فراهم میسازد.‬ ‫,‪Follow us on Facebook‬‬ ‫02‪https://www.facebook.com/Oxus‬‬