SlideShare a Scribd company logo
Question 1
How many parameters does a default constructor have?
Ans) It never has any
Explanation:
The default constructor doesn’t have any parameters.Thats why it is also called as Zero-
Argumented constructor.
Even The default constructor doesn’t return anything even void also.
___________________________________________________________________
Question 2
Which of the following statements is true about the class shown below?
class Quiz1A
{
private int[] array = new int[10];
public int[] getArray()
{
return array;
}
}
Ans) It is immutable
Explanation:
Here the getArray() method is not doing any operations inside it.It just returning an array.So it is
also called as getter method.
______________________________________________________________________
Question 3
A method that is associated with an individual object is called __________.
Ans) an instance method
Explanation:
For every class we can create many objects.If we want to call a method on object, we have to call
a method by using the reference of it.That method is confined to that object only.
______________________________________________________________________
Question 4
Given the declaration Circle[] x = new Circle[10], which of the following statement is most
accurate?
Ans) x contains a reference to an array and each element in the array can hold a reference to a
Circle object.
Explanation:
This array will hold the references of Circle class objects.It will not store objects.
______________________________________________________________________
Question 5
What is the output of the program shown below?
public class Quiz1B
{
public static void main(String[] args)
{
Count count = new Count();
int times = 0;
for (int i = 0; i < 100; i++)
increment(count, times);
System.out.println("times = " + times + " count = " + count.times);
}
public static void increment(Count count, int times)
{
count.times++;
times++;
}
}
class Count
{
int times;
public Count()
{
times = 1;
}
}
Ans) times = 100 count = 101
Explanation:
This for loop in the main method will be executed for 100 times.So the value of the variable of
main method times will increased by 1 for each iteration.As the initial value of times is 0 and
finally it will become 100.after 100 iterations
As the initial value of instance variable of Count class is 1.After 100 iterations its value will
become 101
______________________________________________________________________
Question 6
When calling a method with an object argument, ___________ is passed.
Ans) the reference of the object
Explanation:
We have to pass the reference of an object as argument while calling.not the copy or objects
contents or else.
______________________________________________________________________
Question 7
Which of the following is not a property of a constructor?
Ans) The name of a constructor can be chosen by the programmer
Explanation:
We can overload the constructor.
The constructor is called and executed when we are creating an object by using new operator.
The name of the constructor should be the name of the class.We cannot choose the name of the
constructor.
______________________________________________________________________
Question 8
What is the output of the program shown below?
public class Quiz1C
{
public static void main(String[] args)
{
int i = 1;
StringBuilder s = new StringBuilder("s");
String t = "t";
someMethod(i, s, t);
System.out.print("i = " + i + ", ");
System.out.print("s = " + s + ", ");
System.out.println("t = " + t);
}
private static void someMethod(int i, StringBuilder s, String t)
{
i++;
s.append("s");
t += "t";
}
}
Ans) i = 2, s = ss, t = tt
Explanation:
We are calling the method someMethod(int i, StringBuilder s, String t) by passing the int
variable,references of StringBuilder and String
Inside that i value will be incremented by 1
Appending s to the content of StringBuilder Object.
Concatenating t to the String “t”
______________________________________________________________________
Question 9
Which of the following statements is true about the order of methods in a class.
Ans) They can be listed in any order
Explanation:
We can declare the methods inside the class in any order .there is no restrictions on the order of
declaration of methods.
______________________________________________________________________
Question 10
Which of the following statements about constructors is true?
Ans) A default constructor is provided automatically if no constructors are explicitly declared in
the class
Explanation:
If we didnt provided any constructor in a class,the java compiler will provide the code for default
constructor inside the class while compiling the class.
______________________________________________________________________
Question 11
Which of the following is true about the program shown below?
class Quiz1D
{
private int x;
public Quiz1D(int x)
{
this.x = x;
}
}
Ans) If the this qualifier is removed, it will compile but won't initialize the instance variable
Explanation:
This refers to the current class instance variable.Even If we didn’t provide ‘this’ also our
program will compile but the instance variable will not get initialized.So the instance variable
will be initialized with the default value.
______________________________________________________________________
Question 12
Which of the following statements about local variables is true?
Ans) A compilation error results when a local variable is accessed before it is initialized.
Explanation:
Even if we didn’t initialize the during compilation instance variables will be initialized with their
default values.
But if we want to use local variables compulsory we have to initialize it.If not we will get
compilation error.
______________________________________________________________________
Question 13
Analyze the code shown below and indicate which of the following is true:
class Quiz1E
{
private double variable;
public Quiz1E(double variable)
{
variable = variable;
}
}
Ans)
The program will compile, but you cannot create an object of Quiz1E with a specified value for
variable
Explanation:
As we didn’t provide ‘this’ so the variable will not get initialized.
We wont get any compilation error.But the instance variable value of Quiz1E class will be
initialized with the default values by the java compiler.So as it is double data type it will be
initialized with 0.0
______________________________________________________________________
Question 14
Which of the following is true of public methods?
Ans) They can only be accessed by methods in a different package
Explanation:
The scope of the public access specifier is global.So we can access public methods from
anywhere like with in the class or from with in the package or from outside the package.
______________________________________________________________________
Question 15
Which of the following statements is true about an immutable object?
Ans) The contents of an immutable object cannot be modified
Explanation:
Immutable:
the state or contents of an object cannot be changed or modified.best example for this is String
class .We cannot change the contents of the String class Object contents.
______________________________________________________________________
Question 16
What is the output of the program shown below?
public class Quiz1F
{
private static int i = 0;
public static void main(String[] args)
{
{
int i = 3;
}
System.out.println("i is " + i);
}
}
Ans) i is 0
Explanation:
The scope of the local variable is confined only to the method itself in which it has been
declared.
So if we print ‘i’ 0 will be displayed as output.which is the value of the static variable i.as we
declared private static int i = 0;
______________________________________________________________________
Question 17
Which of the following statements is true of the reserved word this?
Ans) It can be only used in instance methods and constructors
Explanation:
This refer to the current class instance variables.We can use ‘this’ to initialize the instance
variables.
______________________________________________________________________
Question 18
Which of the following statements is true about the class shown below?
public class Quiz1G
{
private void method()
{
}
public static void main(String[] args)
{
method();
}
}
Ans) It won't compile because method needs to be static
Explanation:
First the program wont compile.because we didn’t declare that method as static.To solve the
error we have to declare the method as static.
privatestaticvoid method()
{
System.out.println("x");
}
______________________________________________________________________
Question 19
Which of the following statements is true of private instance variables?
Ans) They can accessed in any instance method in the same class
Explanation:
The scope of the private is confined to the class itself.We can access the private variables only
with in the class in which they have been declared.We can access private instance variables in
any method of the same class.
______________________________________________________________________
Question 20
Which of the following statements about class (static) variables is correct?
Ans) There is only one copy of each class variable that is shared by all instances of the class
Explanation:
Static variable:Only one copy of static variable is shared by all the instances of the class.if we
modified the value of static variable in one object then it will reflects in other objects of the same
class also.
______________________________________________________________
Solution
Question 1
How many parameters does a default constructor have?
Ans) It never has any
Explanation:
The default constructor doesn’t have any parameters.Thats why it is also called as Zero-
Argumented constructor.
Even The default constructor doesn’t return anything even void also.
___________________________________________________________________
Question 2
Which of the following statements is true about the class shown below?
class Quiz1A
{
private int[] array = new int[10];
public int[] getArray()
{
return array;
}
}
Ans) It is immutable
Explanation:
Here the getArray() method is not doing any operations inside it.It just returning an array.So it is
also called as getter method.
______________________________________________________________________
Question 3
A method that is associated with an individual object is called __________.
Ans) an instance method
Explanation:
For every class we can create many objects.If we want to call a method on object, we have to call
a method by using the reference of it.That method is confined to that object only.
______________________________________________________________________
Question 4
Given the declaration Circle[] x = new Circle[10], which of the following statement is most
accurate?
Ans) x contains a reference to an array and each element in the array can hold a reference to a
Circle object.
Explanation:
This array will hold the references of Circle class objects.It will not store objects.
______________________________________________________________________
Question 5
What is the output of the program shown below?
public class Quiz1B
{
public static void main(String[] args)
{
Count count = new Count();
int times = 0;
for (int i = 0; i < 100; i++)
increment(count, times);
System.out.println("times = " + times + " count = " + count.times);
}
public static void increment(Count count, int times)
{
count.times++;
times++;
}
}
class Count
{
int times;
public Count()
{
times = 1;
}
}
Ans) times = 100 count = 101
Explanation:
This for loop in the main method will be executed for 100 times.So the value of the variable of
main method times will increased by 1 for each iteration.As the initial value of times is 0 and
finally it will become 100.after 100 iterations
As the initial value of instance variable of Count class is 1.After 100 iterations its value will
become 101
______________________________________________________________________
Question 6
When calling a method with an object argument, ___________ is passed.
Ans) the reference of the object
Explanation:
We have to pass the reference of an object as argument while calling.not the copy or objects
contents or else.
______________________________________________________________________
Question 7
Which of the following is not a property of a constructor?
Ans) The name of a constructor can be chosen by the programmer
Explanation:
We can overload the constructor.
The constructor is called and executed when we are creating an object by using new operator.
The name of the constructor should be the name of the class.We cannot choose the name of the
constructor.
______________________________________________________________________
Question 8
What is the output of the program shown below?
public class Quiz1C
{
public static void main(String[] args)
{
int i = 1;
StringBuilder s = new StringBuilder("s");
String t = "t";
someMethod(i, s, t);
System.out.print("i = " + i + ", ");
System.out.print("s = " + s + ", ");
System.out.println("t = " + t);
}
private static void someMethod(int i, StringBuilder s, String t)
{
i++;
s.append("s");
t += "t";
}
}
Ans) i = 2, s = ss, t = tt
Explanation:
We are calling the method someMethod(int i, StringBuilder s, String t) by passing the int
variable,references of StringBuilder and String
Inside that i value will be incremented by 1
Appending s to the content of StringBuilder Object.
Concatenating t to the String “t”
______________________________________________________________________
Question 9
Which of the following statements is true about the order of methods in a class.
Ans) They can be listed in any order
Explanation:
We can declare the methods inside the class in any order .there is no restrictions on the order of
declaration of methods.
______________________________________________________________________
Question 10
Which of the following statements about constructors is true?
Ans) A default constructor is provided automatically if no constructors are explicitly declared in
the class
Explanation:
If we didnt provided any constructor in a class,the java compiler will provide the code for default
constructor inside the class while compiling the class.
______________________________________________________________________
Question 11
Which of the following is true about the program shown below?
class Quiz1D
{
private int x;
public Quiz1D(int x)
{
this.x = x;
}
}
Ans) If the this qualifier is removed, it will compile but won't initialize the instance variable
Explanation:
This refers to the current class instance variable.Even If we didn’t provide ‘this’ also our
program will compile but the instance variable will not get initialized.So the instance variable
will be initialized with the default value.
______________________________________________________________________
Question 12
Which of the following statements about local variables is true?
Ans) A compilation error results when a local variable is accessed before it is initialized.
Explanation:
Even if we didn’t initialize the during compilation instance variables will be initialized with their
default values.
But if we want to use local variables compulsory we have to initialize it.If not we will get
compilation error.
______________________________________________________________________
Question 13
Analyze the code shown below and indicate which of the following is true:
class Quiz1E
{
private double variable;
public Quiz1E(double variable)
{
variable = variable;
}
}
Ans)
The program will compile, but you cannot create an object of Quiz1E with a specified value for
variable
Explanation:
As we didn’t provide ‘this’ so the variable will not get initialized.
We wont get any compilation error.But the instance variable value of Quiz1E class will be
initialized with the default values by the java compiler.So as it is double data type it will be
initialized with 0.0
______________________________________________________________________
Question 14
Which of the following is true of public methods?
Ans) They can only be accessed by methods in a different package
Explanation:
The scope of the public access specifier is global.So we can access public methods from
anywhere like with in the class or from with in the package or from outside the package.
______________________________________________________________________
Question 15
Which of the following statements is true about an immutable object?
Ans) The contents of an immutable object cannot be modified
Explanation:
Immutable:
the state or contents of an object cannot be changed or modified.best example for this is String
class .We cannot change the contents of the String class Object contents.
______________________________________________________________________
Question 16
What is the output of the program shown below?
public class Quiz1F
{
private static int i = 0;
public static void main(String[] args)
{
{
int i = 3;
}
System.out.println("i is " + i);
}
}
Ans) i is 0
Explanation:
The scope of the local variable is confined only to the method itself in which it has been
declared.
So if we print ‘i’ 0 will be displayed as output.which is the value of the static variable i.as we
declared private static int i = 0;
______________________________________________________________________
Question 17
Which of the following statements is true of the reserved word this?
Ans) It can be only used in instance methods and constructors
Explanation:
This refer to the current class instance variables.We can use ‘this’ to initialize the instance
variables.
______________________________________________________________________
Question 18
Which of the following statements is true about the class shown below?
public class Quiz1G
{
private void method()
{
}
public static void main(String[] args)
{
method();
}
}
Ans) It won't compile because method needs to be static
Explanation:
First the program wont compile.because we didn’t declare that method as static.To solve the
error we have to declare the method as static.
privatestaticvoid method()
{
System.out.println("x");
}
______________________________________________________________________
Question 19
Which of the following statements is true of private instance variables?
Ans) They can accessed in any instance method in the same class
Explanation:
The scope of the private is confined to the class itself.We can access the private variables only
with in the class in which they have been declared.We can access private instance variables in
any method of the same class.
______________________________________________________________________
Question 20
Which of the following statements about class (static) variables is correct?
Ans) There is only one copy of each class variable that is shared by all instances of the class
Explanation:
Static variable:Only one copy of static variable is shared by all the instances of the class.if we
modified the value of static variable in one object then it will reflects in other objects of the same
class also.
______________________________________________________________

More Related Content

Similar to Question 1How many parameters does a default constructor haveAn.pdf

Tameeka Final Exam (Answer Key)1.Solve the following line.docx
Tameeka Final Exam (Answer Key)1.Solve the following line.docxTameeka Final Exam (Answer Key)1.Solve the following line.docx
Tameeka Final Exam (Answer Key)1.Solve the following line.docx
deanmtaylor1545
 
Tameeka Final Exam (Answer Key)1.Solve the following line.docx
Tameeka Final Exam (Answer Key)1.Solve the following line.docxTameeka Final Exam (Answer Key)1.Solve the following line.docx
Tameeka Final Exam (Answer Key)1.Solve the following line.docx
bradburgess22840
 
Accessing non static members from the main
Accessing non static members from the mainAccessing non static members from the main
Accessing non static members from the main
Tutors On Net
 
Accessing non static members from the main
Accessing non static members from the mainAccessing non static members from the main
Accessing non static members from the main
Tutors On Net
 
08review (1)
08review (1)08review (1)
08review (1)
IIUM
 
Name________________________________________________ Block________.docx
Name________________________________________________ Block________.docxName________________________________________________ Block________.docx
Name________________________________________________ Block________.docx
hallettfaustina
 
Question 1 1 pts Skip to question text.As part of a bank account.docx
Question 1 1 pts Skip to question text.As part of a bank account.docxQuestion 1 1 pts Skip to question text.As part of a bank account.docx
Question 1 1 pts Skip to question text.As part of a bank account.docx
amrit47
 
CIS 407 STUDY Inspiring Innovation--cis407study.com
CIS 407 STUDY Inspiring Innovation--cis407study.comCIS 407 STUDY Inspiring Innovation--cis407study.com
CIS 407 STUDY Inspiring Innovation--cis407study.com
KeatonJennings91
 
Delphi qa
Delphi qaDelphi qa
Delphi qa
sandy14234
 
Deciphering the Ruby Object Model
Deciphering the Ruby Object ModelDeciphering the Ruby Object Model
Deciphering the Ruby Object Model
Karthik Sirasanagandla
 
Final Report
Final ReportFinal Report
Final Report
Aman Soni
 
Introduction to Ruby’s Reflection API
Introduction to Ruby’s Reflection APIIntroduction to Ruby’s Reflection API
Introduction to Ruby’s Reflection API
Niranjan Sarade
 
Guide
GuideGuide
Practice Test 5B Multinomial Experiments and Contingency Tables
Practice Test 5B Multinomial Experiments and Contingency TablesPractice Test 5B Multinomial Experiments and Contingency Tables
Practice Test 5B Multinomial Experiments and Contingency Tables
Long Beach City College
 
Practice Test 5B Multinomial Experiments and Contingency Tables
Practice Test 5B Multinomial Experiments and Contingency TablesPractice Test 5B Multinomial Experiments and Contingency Tables
Practice Test 5B Multinomial Experiments and Contingency Tables
Long Beach City College
 
Lecture 5
Lecture 5Lecture 5
Lecture 5
talha ijaz
 
Hemajava
HemajavaHemajava
Hemajava
SangeethaSasi1
 
CIS 1403 lab 3 functions and methods in Java
CIS 1403 lab 3 functions and methods in JavaCIS 1403 lab 3 functions and methods in Java
CIS 1403 lab 3 functions and methods in Java
Hamad Odhabi
 
Rechecking SharpDevelop: Any New Bugs?
Rechecking SharpDevelop: Any New Bugs?Rechecking SharpDevelop: Any New Bugs?
Rechecking SharpDevelop: Any New Bugs?
PVS-Studio
 

Similar to Question 1How many parameters does a default constructor haveAn.pdf (19)

Tameeka Final Exam (Answer Key)1.Solve the following line.docx
Tameeka Final Exam (Answer Key)1.Solve the following line.docxTameeka Final Exam (Answer Key)1.Solve the following line.docx
Tameeka Final Exam (Answer Key)1.Solve the following line.docx
 
Tameeka Final Exam (Answer Key)1.Solve the following line.docx
Tameeka Final Exam (Answer Key)1.Solve the following line.docxTameeka Final Exam (Answer Key)1.Solve the following line.docx
Tameeka Final Exam (Answer Key)1.Solve the following line.docx
 
Accessing non static members from the main
Accessing non static members from the mainAccessing non static members from the main
Accessing non static members from the main
 
Accessing non static members from the main
Accessing non static members from the mainAccessing non static members from the main
Accessing non static members from the main
 
08review (1)
08review (1)08review (1)
08review (1)
 
Name________________________________________________ Block________.docx
Name________________________________________________ Block________.docxName________________________________________________ Block________.docx
Name________________________________________________ Block________.docx
 
Question 1 1 pts Skip to question text.As part of a bank account.docx
Question 1 1 pts Skip to question text.As part of a bank account.docxQuestion 1 1 pts Skip to question text.As part of a bank account.docx
Question 1 1 pts Skip to question text.As part of a bank account.docx
 
CIS 407 STUDY Inspiring Innovation--cis407study.com
CIS 407 STUDY Inspiring Innovation--cis407study.comCIS 407 STUDY Inspiring Innovation--cis407study.com
CIS 407 STUDY Inspiring Innovation--cis407study.com
 
Delphi qa
Delphi qaDelphi qa
Delphi qa
 
Deciphering the Ruby Object Model
Deciphering the Ruby Object ModelDeciphering the Ruby Object Model
Deciphering the Ruby Object Model
 
Final Report
Final ReportFinal Report
Final Report
 
Introduction to Ruby’s Reflection API
Introduction to Ruby’s Reflection APIIntroduction to Ruby’s Reflection API
Introduction to Ruby’s Reflection API
 
Guide
GuideGuide
Guide
 
Practice Test 5B Multinomial Experiments and Contingency Tables
Practice Test 5B Multinomial Experiments and Contingency TablesPractice Test 5B Multinomial Experiments and Contingency Tables
Practice Test 5B Multinomial Experiments and Contingency Tables
 
Practice Test 5B Multinomial Experiments and Contingency Tables
Practice Test 5B Multinomial Experiments and Contingency TablesPractice Test 5B Multinomial Experiments and Contingency Tables
Practice Test 5B Multinomial Experiments and Contingency Tables
 
Lecture 5
Lecture 5Lecture 5
Lecture 5
 
Hemajava
HemajavaHemajava
Hemajava
 
CIS 1403 lab 3 functions and methods in Java
CIS 1403 lab 3 functions and methods in JavaCIS 1403 lab 3 functions and methods in Java
CIS 1403 lab 3 functions and methods in Java
 
Rechecking SharpDevelop: Any New Bugs?
Rechecking SharpDevelop: Any New Bugs?Rechecking SharpDevelop: Any New Bugs?
Rechecking SharpDevelop: Any New Bugs?
 

More from arccreation001

SOURCE CODEimport java.util.Iterator;public class CircularLinke.pdf
SOURCE CODEimport java.util.Iterator;public class CircularLinke.pdfSOURCE CODEimport java.util.Iterator;public class CircularLinke.pdf
SOURCE CODEimport java.util.Iterator;public class CircularLinke.pdf
arccreation001
 
2) In Autocrine signalling, reception of a signal released by the sa.pdf
2) In Autocrine signalling, reception of a signal released by the sa.pdf2) In Autocrine signalling, reception of a signal released by the sa.pdf
2) In Autocrine signalling, reception of a signal released by the sa.pdf
arccreation001
 
Volatility Distillation separates out different .pdf
                     Volatility  Distillation separates out different .pdf                     Volatility  Distillation separates out different .pdf
Volatility Distillation separates out different .pdf
arccreation001
 
The first one has Van der Waals interactions sinc.pdf
                     The first one has Van der Waals interactions sinc.pdf                     The first one has Van der Waals interactions sinc.pdf
The first one has Van der Waals interactions sinc.pdf
arccreation001
 
Supersaturated actually. There is more solvent th.pdf
                     Supersaturated actually. There is more solvent th.pdf                     Supersaturated actually. There is more solvent th.pdf
Supersaturated actually. There is more solvent th.pdf
arccreation001
 
In optics, a virtual image is an image in which t.pdf
                     In optics, a virtual image is an image in which t.pdf                     In optics, a virtual image is an image in which t.pdf
In optics, a virtual image is an image in which t.pdf
arccreation001
 
1) Political orientation and ideas are the main reasons behind count.pdf
1) Political orientation and ideas are the main reasons behind count.pdf1) Political orientation and ideas are the main reasons behind count.pdf
1) Political orientation and ideas are the main reasons behind count.pdf
arccreation001
 
Molarity = moles volume in L Molarity = 0.0342.pdf
                     Molarity = moles  volume in L Molarity = 0.0342.pdf                     Molarity = moles  volume in L Molarity = 0.0342.pdf
Molarity = moles volume in L Molarity = 0.0342.pdf
arccreation001
 
The tracheal system in insects and gills in fishes are both helps th.pdf
The tracheal system in insects and gills in fishes are both helps th.pdfThe tracheal system in insects and gills in fishes are both helps th.pdf
The tracheal system in insects and gills in fishes are both helps th.pdf
arccreation001
 
The answer is D. ChemoorganoheterotrophCow is a chemoorganohetero.pdf
The answer is D. ChemoorganoheterotrophCow is a chemoorganohetero.pdfThe answer is D. ChemoorganoheterotrophCow is a chemoorganohetero.pdf
The answer is D. ChemoorganoheterotrophCow is a chemoorganohetero.pdf
arccreation001
 
The A and B chains of human insulin are cloned in separate plasmids .pdf
The A and B chains of human insulin are cloned in separate plasmids .pdfThe A and B chains of human insulin are cloned in separate plasmids .pdf
The A and B chains of human insulin are cloned in separate plasmids .pdf
arccreation001
 
Rio de Janeiro is a city located on Brazils south-east coast. It i.pdf
Rio de Janeiro is a city located on Brazils south-east coast. It i.pdfRio de Janeiro is a city located on Brazils south-east coast. It i.pdf
Rio de Janeiro is a city located on Brazils south-east coast. It i.pdf
arccreation001
 
Othello.javapackage othello;import core.Game; import userInter.pdf
Othello.javapackage othello;import core.Game; import userInter.pdfOthello.javapackage othello;import core.Game; import userInter.pdf
Othello.javapackage othello;import core.Game; import userInter.pdf
arccreation001
 
1.Types of Computer Information SystemsThere are four basic type.pdf
1.Types of Computer Information SystemsThere are four basic type.pdf1.Types of Computer Information SystemsThere are four basic type.pdf
1.Types of Computer Information SystemsThere are four basic type.pdf
arccreation001
 
Microbiome of human bodyResearchers currently studying human norm.pdf
Microbiome of human bodyResearchers currently studying human norm.pdfMicrobiome of human bodyResearchers currently studying human norm.pdf
Microbiome of human bodyResearchers currently studying human norm.pdf
arccreation001
 
Na2SeO3 --- 2 Na+ + SeO32- 0.08              0.16       0.08 .pdf
Na2SeO3 --- 2 Na+ + SeO32- 0.08              0.16       0.08 .pdfNa2SeO3 --- 2 Na+ + SeO32- 0.08              0.16       0.08 .pdf
Na2SeO3 --- 2 Na+ + SeO32- 0.08              0.16       0.08 .pdf
arccreation001
 
It is an important to understand the early stages of reproduction. W.pdf
It is an important to understand the early stages of reproduction. W.pdfIt is an important to understand the early stages of reproduction. W.pdf
It is an important to understand the early stages of reproduction. W.pdf
arccreation001
 
Let the normal gene be represented by P, and the two mutations be re.pdf
Let the normal gene be represented by P, and the two mutations be re.pdfLet the normal gene be represented by P, and the two mutations be re.pdf
Let the normal gene be represented by P, and the two mutations be re.pdf
arccreation001
 
Imagine you are an Information Systems Security Officer for a medium.pdf
Imagine you are an Information Systems Security Officer for a medium.pdfImagine you are an Information Systems Security Officer for a medium.pdf
Imagine you are an Information Systems Security Officer for a medium.pdf
arccreation001
 
Each water molecule has 4 hydrogen bonds holding .pdf
                     Each water molecule has 4 hydrogen bonds holding .pdf                     Each water molecule has 4 hydrogen bonds holding .pdf
Each water molecule has 4 hydrogen bonds holding .pdf
arccreation001
 

More from arccreation001 (20)

SOURCE CODEimport java.util.Iterator;public class CircularLinke.pdf
SOURCE CODEimport java.util.Iterator;public class CircularLinke.pdfSOURCE CODEimport java.util.Iterator;public class CircularLinke.pdf
SOURCE CODEimport java.util.Iterator;public class CircularLinke.pdf
 
2) In Autocrine signalling, reception of a signal released by the sa.pdf
2) In Autocrine signalling, reception of a signal released by the sa.pdf2) In Autocrine signalling, reception of a signal released by the sa.pdf
2) In Autocrine signalling, reception of a signal released by the sa.pdf
 
Volatility Distillation separates out different .pdf
                     Volatility  Distillation separates out different .pdf                     Volatility  Distillation separates out different .pdf
Volatility Distillation separates out different .pdf
 
The first one has Van der Waals interactions sinc.pdf
                     The first one has Van der Waals interactions sinc.pdf                     The first one has Van der Waals interactions sinc.pdf
The first one has Van der Waals interactions sinc.pdf
 
Supersaturated actually. There is more solvent th.pdf
                     Supersaturated actually. There is more solvent th.pdf                     Supersaturated actually. There is more solvent th.pdf
Supersaturated actually. There is more solvent th.pdf
 
In optics, a virtual image is an image in which t.pdf
                     In optics, a virtual image is an image in which t.pdf                     In optics, a virtual image is an image in which t.pdf
In optics, a virtual image is an image in which t.pdf
 
1) Political orientation and ideas are the main reasons behind count.pdf
1) Political orientation and ideas are the main reasons behind count.pdf1) Political orientation and ideas are the main reasons behind count.pdf
1) Political orientation and ideas are the main reasons behind count.pdf
 
Molarity = moles volume in L Molarity = 0.0342.pdf
                     Molarity = moles  volume in L Molarity = 0.0342.pdf                     Molarity = moles  volume in L Molarity = 0.0342.pdf
Molarity = moles volume in L Molarity = 0.0342.pdf
 
The tracheal system in insects and gills in fishes are both helps th.pdf
The tracheal system in insects and gills in fishes are both helps th.pdfThe tracheal system in insects and gills in fishes are both helps th.pdf
The tracheal system in insects and gills in fishes are both helps th.pdf
 
The answer is D. ChemoorganoheterotrophCow is a chemoorganohetero.pdf
The answer is D. ChemoorganoheterotrophCow is a chemoorganohetero.pdfThe answer is D. ChemoorganoheterotrophCow is a chemoorganohetero.pdf
The answer is D. ChemoorganoheterotrophCow is a chemoorganohetero.pdf
 
The A and B chains of human insulin are cloned in separate plasmids .pdf
The A and B chains of human insulin are cloned in separate plasmids .pdfThe A and B chains of human insulin are cloned in separate plasmids .pdf
The A and B chains of human insulin are cloned in separate plasmids .pdf
 
Rio de Janeiro is a city located on Brazils south-east coast. It i.pdf
Rio de Janeiro is a city located on Brazils south-east coast. It i.pdfRio de Janeiro is a city located on Brazils south-east coast. It i.pdf
Rio de Janeiro is a city located on Brazils south-east coast. It i.pdf
 
Othello.javapackage othello;import core.Game; import userInter.pdf
Othello.javapackage othello;import core.Game; import userInter.pdfOthello.javapackage othello;import core.Game; import userInter.pdf
Othello.javapackage othello;import core.Game; import userInter.pdf
 
1.Types of Computer Information SystemsThere are four basic type.pdf
1.Types of Computer Information SystemsThere are four basic type.pdf1.Types of Computer Information SystemsThere are four basic type.pdf
1.Types of Computer Information SystemsThere are four basic type.pdf
 
Microbiome of human bodyResearchers currently studying human norm.pdf
Microbiome of human bodyResearchers currently studying human norm.pdfMicrobiome of human bodyResearchers currently studying human norm.pdf
Microbiome of human bodyResearchers currently studying human norm.pdf
 
Na2SeO3 --- 2 Na+ + SeO32- 0.08              0.16       0.08 .pdf
Na2SeO3 --- 2 Na+ + SeO32- 0.08              0.16       0.08 .pdfNa2SeO3 --- 2 Na+ + SeO32- 0.08              0.16       0.08 .pdf
Na2SeO3 --- 2 Na+ + SeO32- 0.08              0.16       0.08 .pdf
 
It is an important to understand the early stages of reproduction. W.pdf
It is an important to understand the early stages of reproduction. W.pdfIt is an important to understand the early stages of reproduction. W.pdf
It is an important to understand the early stages of reproduction. W.pdf
 
Let the normal gene be represented by P, and the two mutations be re.pdf
Let the normal gene be represented by P, and the two mutations be re.pdfLet the normal gene be represented by P, and the two mutations be re.pdf
Let the normal gene be represented by P, and the two mutations be re.pdf
 
Imagine you are an Information Systems Security Officer for a medium.pdf
Imagine you are an Information Systems Security Officer for a medium.pdfImagine you are an Information Systems Security Officer for a medium.pdf
Imagine you are an Information Systems Security Officer for a medium.pdf
 
Each water molecule has 4 hydrogen bonds holding .pdf
                     Each water molecule has 4 hydrogen bonds holding .pdf                     Each water molecule has 4 hydrogen bonds holding .pdf
Each water molecule has 4 hydrogen bonds holding .pdf
 

Recently uploaded

Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...
PsychoTech Services
 
skeleton System.pdf (skeleton system wow)
skeleton System.pdf (skeleton system wow)skeleton System.pdf (skeleton system wow)
skeleton System.pdf (skeleton system wow)
Mohammad Al-Dhahabi
 
مصحف القراءات العشر أعد أحرف الخلاف سمير بسيوني.pdf
مصحف القراءات العشر   أعد أحرف الخلاف سمير بسيوني.pdfمصحف القراءات العشر   أعد أحرف الخلاف سمير بسيوني.pdf
مصحف القراءات العشر أعد أحرف الخلاف سمير بسيوني.pdf
سمير بسيوني
 
CIS 4200-02 Group 1 Final Project Report (1).pdf
CIS 4200-02 Group 1 Final Project Report (1).pdfCIS 4200-02 Group 1 Final Project Report (1).pdf
CIS 4200-02 Group 1 Final Project Report (1).pdf
blueshagoo1
 
Bonku-Babus-Friend by Sathyajith Ray (9)
Bonku-Babus-Friend by Sathyajith Ray  (9)Bonku-Babus-Friend by Sathyajith Ray  (9)
Bonku-Babus-Friend by Sathyajith Ray (9)
nitinpv4ai
 
Benner "Expanding Pathways to Publishing Careers"
Benner "Expanding Pathways to Publishing Careers"Benner "Expanding Pathways to Publishing Careers"
Benner "Expanding Pathways to Publishing Careers"
National Information Standards Organization (NISO)
 
Bossa N’ Roll Records by Ismael Vazquez.
Bossa N’ Roll Records by Ismael Vazquez.Bossa N’ Roll Records by Ismael Vazquez.
Bossa N’ Roll Records by Ismael Vazquez.
IsmaelVazquez38
 
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
Nguyen Thanh Tu Collection
 
How Barcodes Can Be Leveraged Within Odoo 17
How Barcodes Can Be Leveraged Within Odoo 17How Barcodes Can Be Leveraged Within Odoo 17
How Barcodes Can Be Leveraged Within Odoo 17
Celine George
 
Educational Technology in the Health Sciences
Educational Technology in the Health SciencesEducational Technology in the Health Sciences
Educational Technology in the Health Sciences
Iris Thiele Isip-Tan
 
Temple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation resultsTemple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation results
Krassimira Luka
 
Data Structure using C by Dr. K Adisesha .ppsx
Data Structure using C by Dr. K Adisesha .ppsxData Structure using C by Dr. K Adisesha .ppsx
Data Structure using C by Dr. K Adisesha .ppsx
Prof. Dr. K. Adisesha
 
Wound healing PPT
Wound healing PPTWound healing PPT
Wound healing PPT
Jyoti Chand
 
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
Nguyen Thanh Tu Collection
 
Electric Fetus - Record Store Scavenger Hunt
Electric Fetus - Record Store Scavenger HuntElectric Fetus - Record Store Scavenger Hunt
Electric Fetus - Record Store Scavenger Hunt
RamseyBerglund
 
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptxNEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
iammrhaywood
 
Juneteenth Freedom Day 2024 David Douglas School District
Juneteenth Freedom Day 2024 David Douglas School DistrictJuneteenth Freedom Day 2024 David Douglas School District
Juneteenth Freedom Day 2024 David Douglas School District
David Douglas School District
 
SWOT analysis in the project Keeping the Memory @live.pptx
SWOT analysis in the project Keeping the Memory @live.pptxSWOT analysis in the project Keeping the Memory @live.pptx
SWOT analysis in the project Keeping the Memory @live.pptx
zuzanka
 
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptxBIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
RidwanHassanYusuf
 
MDP on air pollution of class 8 year 2024-2025
MDP on air pollution of class 8 year 2024-2025MDP on air pollution of class 8 year 2024-2025
MDP on air pollution of class 8 year 2024-2025
khuleseema60
 

Recently uploaded (20)

Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...
 
skeleton System.pdf (skeleton system wow)
skeleton System.pdf (skeleton system wow)skeleton System.pdf (skeleton system wow)
skeleton System.pdf (skeleton system wow)
 
مصحف القراءات العشر أعد أحرف الخلاف سمير بسيوني.pdf
مصحف القراءات العشر   أعد أحرف الخلاف سمير بسيوني.pdfمصحف القراءات العشر   أعد أحرف الخلاف سمير بسيوني.pdf
مصحف القراءات العشر أعد أحرف الخلاف سمير بسيوني.pdf
 
CIS 4200-02 Group 1 Final Project Report (1).pdf
CIS 4200-02 Group 1 Final Project Report (1).pdfCIS 4200-02 Group 1 Final Project Report (1).pdf
CIS 4200-02 Group 1 Final Project Report (1).pdf
 
Bonku-Babus-Friend by Sathyajith Ray (9)
Bonku-Babus-Friend by Sathyajith Ray  (9)Bonku-Babus-Friend by Sathyajith Ray  (9)
Bonku-Babus-Friend by Sathyajith Ray (9)
 
Benner "Expanding Pathways to Publishing Careers"
Benner "Expanding Pathways to Publishing Careers"Benner "Expanding Pathways to Publishing Careers"
Benner "Expanding Pathways to Publishing Careers"
 
Bossa N’ Roll Records by Ismael Vazquez.
Bossa N’ Roll Records by Ismael Vazquez.Bossa N’ Roll Records by Ismael Vazquez.
Bossa N’ Roll Records by Ismael Vazquez.
 
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
 
How Barcodes Can Be Leveraged Within Odoo 17
How Barcodes Can Be Leveraged Within Odoo 17How Barcodes Can Be Leveraged Within Odoo 17
How Barcodes Can Be Leveraged Within Odoo 17
 
Educational Technology in the Health Sciences
Educational Technology in the Health SciencesEducational Technology in the Health Sciences
Educational Technology in the Health Sciences
 
Temple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation resultsTemple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation results
 
Data Structure using C by Dr. K Adisesha .ppsx
Data Structure using C by Dr. K Adisesha .ppsxData Structure using C by Dr. K Adisesha .ppsx
Data Structure using C by Dr. K Adisesha .ppsx
 
Wound healing PPT
Wound healing PPTWound healing PPT
Wound healing PPT
 
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
 
Electric Fetus - Record Store Scavenger Hunt
Electric Fetus - Record Store Scavenger HuntElectric Fetus - Record Store Scavenger Hunt
Electric Fetus - Record Store Scavenger Hunt
 
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptxNEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
 
Juneteenth Freedom Day 2024 David Douglas School District
Juneteenth Freedom Day 2024 David Douglas School DistrictJuneteenth Freedom Day 2024 David Douglas School District
Juneteenth Freedom Day 2024 David Douglas School District
 
SWOT analysis in the project Keeping the Memory @live.pptx
SWOT analysis in the project Keeping the Memory @live.pptxSWOT analysis in the project Keeping the Memory @live.pptx
SWOT analysis in the project Keeping the Memory @live.pptx
 
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptxBIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
 
MDP on air pollution of class 8 year 2024-2025
MDP on air pollution of class 8 year 2024-2025MDP on air pollution of class 8 year 2024-2025
MDP on air pollution of class 8 year 2024-2025
 

Question 1How many parameters does a default constructor haveAn.pdf

  • 1. Question 1 How many parameters does a default constructor have? Ans) It never has any Explanation: The default constructor doesn’t have any parameters.Thats why it is also called as Zero- Argumented constructor. Even The default constructor doesn’t return anything even void also. ___________________________________________________________________ Question 2 Which of the following statements is true about the class shown below? class Quiz1A { private int[] array = new int[10]; public int[] getArray() { return array; } } Ans) It is immutable Explanation: Here the getArray() method is not doing any operations inside it.It just returning an array.So it is also called as getter method. ______________________________________________________________________ Question 3 A method that is associated with an individual object is called __________. Ans) an instance method Explanation: For every class we can create many objects.If we want to call a method on object, we have to call a method by using the reference of it.That method is confined to that object only. ______________________________________________________________________ Question 4 Given the declaration Circle[] x = new Circle[10], which of the following statement is most accurate? Ans) x contains a reference to an array and each element in the array can hold a reference to a
  • 2. Circle object. Explanation: This array will hold the references of Circle class objects.It will not store objects. ______________________________________________________________________ Question 5 What is the output of the program shown below? public class Quiz1B { public static void main(String[] args) { Count count = new Count(); int times = 0; for (int i = 0; i < 100; i++) increment(count, times); System.out.println("times = " + times + " count = " + count.times); } public static void increment(Count count, int times) { count.times++; times++; } } class Count { int times; public Count() { times = 1; } } Ans) times = 100 count = 101
  • 3. Explanation: This for loop in the main method will be executed for 100 times.So the value of the variable of main method times will increased by 1 for each iteration.As the initial value of times is 0 and finally it will become 100.after 100 iterations As the initial value of instance variable of Count class is 1.After 100 iterations its value will become 101 ______________________________________________________________________ Question 6 When calling a method with an object argument, ___________ is passed. Ans) the reference of the object Explanation: We have to pass the reference of an object as argument while calling.not the copy or objects contents or else. ______________________________________________________________________ Question 7 Which of the following is not a property of a constructor? Ans) The name of a constructor can be chosen by the programmer Explanation: We can overload the constructor. The constructor is called and executed when we are creating an object by using new operator. The name of the constructor should be the name of the class.We cannot choose the name of the constructor. ______________________________________________________________________ Question 8 What is the output of the program shown below? public class Quiz1C { public static void main(String[] args) { int i = 1; StringBuilder s = new StringBuilder("s"); String t = "t"; someMethod(i, s, t); System.out.print("i = " + i + ", ");
  • 4. System.out.print("s = " + s + ", "); System.out.println("t = " + t); } private static void someMethod(int i, StringBuilder s, String t) { i++; s.append("s"); t += "t"; } } Ans) i = 2, s = ss, t = tt Explanation: We are calling the method someMethod(int i, StringBuilder s, String t) by passing the int variable,references of StringBuilder and String Inside that i value will be incremented by 1 Appending s to the content of StringBuilder Object. Concatenating t to the String “t” ______________________________________________________________________ Question 9 Which of the following statements is true about the order of methods in a class. Ans) They can be listed in any order Explanation: We can declare the methods inside the class in any order .there is no restrictions on the order of declaration of methods. ______________________________________________________________________ Question 10 Which of the following statements about constructors is true? Ans) A default constructor is provided automatically if no constructors are explicitly declared in the class Explanation: If we didnt provided any constructor in a class,the java compiler will provide the code for default constructor inside the class while compiling the class. ______________________________________________________________________ Question 11 Which of the following is true about the program shown below?
  • 5. class Quiz1D { private int x; public Quiz1D(int x) { this.x = x; } } Ans) If the this qualifier is removed, it will compile but won't initialize the instance variable Explanation: This refers to the current class instance variable.Even If we didn’t provide ‘this’ also our program will compile but the instance variable will not get initialized.So the instance variable will be initialized with the default value. ______________________________________________________________________ Question 12 Which of the following statements about local variables is true? Ans) A compilation error results when a local variable is accessed before it is initialized. Explanation: Even if we didn’t initialize the during compilation instance variables will be initialized with their default values. But if we want to use local variables compulsory we have to initialize it.If not we will get compilation error. ______________________________________________________________________ Question 13 Analyze the code shown below and indicate which of the following is true: class Quiz1E { private double variable; public Quiz1E(double variable) { variable = variable; }
  • 6. } Ans) The program will compile, but you cannot create an object of Quiz1E with a specified value for variable Explanation: As we didn’t provide ‘this’ so the variable will not get initialized. We wont get any compilation error.But the instance variable value of Quiz1E class will be initialized with the default values by the java compiler.So as it is double data type it will be initialized with 0.0 ______________________________________________________________________ Question 14 Which of the following is true of public methods? Ans) They can only be accessed by methods in a different package Explanation: The scope of the public access specifier is global.So we can access public methods from anywhere like with in the class or from with in the package or from outside the package. ______________________________________________________________________ Question 15 Which of the following statements is true about an immutable object? Ans) The contents of an immutable object cannot be modified Explanation: Immutable: the state or contents of an object cannot be changed or modified.best example for this is String class .We cannot change the contents of the String class Object contents. ______________________________________________________________________ Question 16 What is the output of the program shown below? public class Quiz1F { private static int i = 0; public static void main(String[] args) { { int i = 3;
  • 7. } System.out.println("i is " + i); } } Ans) i is 0 Explanation: The scope of the local variable is confined only to the method itself in which it has been declared. So if we print ‘i’ 0 will be displayed as output.which is the value of the static variable i.as we declared private static int i = 0; ______________________________________________________________________ Question 17 Which of the following statements is true of the reserved word this? Ans) It can be only used in instance methods and constructors Explanation: This refer to the current class instance variables.We can use ‘this’ to initialize the instance variables. ______________________________________________________________________ Question 18 Which of the following statements is true about the class shown below? public class Quiz1G { private void method() { } public static void main(String[] args) { method(); } } Ans) It won't compile because method needs to be static Explanation: First the program wont compile.because we didn’t declare that method as static.To solve the error we have to declare the method as static.
  • 8. privatestaticvoid method() { System.out.println("x"); } ______________________________________________________________________ Question 19 Which of the following statements is true of private instance variables? Ans) They can accessed in any instance method in the same class Explanation: The scope of the private is confined to the class itself.We can access the private variables only with in the class in which they have been declared.We can access private instance variables in any method of the same class. ______________________________________________________________________ Question 20 Which of the following statements about class (static) variables is correct? Ans) There is only one copy of each class variable that is shared by all instances of the class Explanation: Static variable:Only one copy of static variable is shared by all the instances of the class.if we modified the value of static variable in one object then it will reflects in other objects of the same class also. ______________________________________________________________ Solution Question 1 How many parameters does a default constructor have? Ans) It never has any Explanation: The default constructor doesn’t have any parameters.Thats why it is also called as Zero- Argumented constructor. Even The default constructor doesn’t return anything even void also. ___________________________________________________________________ Question 2 Which of the following statements is true about the class shown below?
  • 9. class Quiz1A { private int[] array = new int[10]; public int[] getArray() { return array; } } Ans) It is immutable Explanation: Here the getArray() method is not doing any operations inside it.It just returning an array.So it is also called as getter method. ______________________________________________________________________ Question 3 A method that is associated with an individual object is called __________. Ans) an instance method Explanation: For every class we can create many objects.If we want to call a method on object, we have to call a method by using the reference of it.That method is confined to that object only. ______________________________________________________________________ Question 4 Given the declaration Circle[] x = new Circle[10], which of the following statement is most accurate? Ans) x contains a reference to an array and each element in the array can hold a reference to a Circle object. Explanation: This array will hold the references of Circle class objects.It will not store objects. ______________________________________________________________________ Question 5 What is the output of the program shown below? public class Quiz1B { public static void main(String[] args) { Count count = new Count();
  • 10. int times = 0; for (int i = 0; i < 100; i++) increment(count, times); System.out.println("times = " + times + " count = " + count.times); } public static void increment(Count count, int times) { count.times++; times++; } } class Count { int times; public Count() { times = 1; } } Ans) times = 100 count = 101 Explanation: This for loop in the main method will be executed for 100 times.So the value of the variable of main method times will increased by 1 for each iteration.As the initial value of times is 0 and finally it will become 100.after 100 iterations As the initial value of instance variable of Count class is 1.After 100 iterations its value will become 101 ______________________________________________________________________ Question 6 When calling a method with an object argument, ___________ is passed. Ans) the reference of the object Explanation: We have to pass the reference of an object as argument while calling.not the copy or objects
  • 11. contents or else. ______________________________________________________________________ Question 7 Which of the following is not a property of a constructor? Ans) The name of a constructor can be chosen by the programmer Explanation: We can overload the constructor. The constructor is called and executed when we are creating an object by using new operator. The name of the constructor should be the name of the class.We cannot choose the name of the constructor. ______________________________________________________________________ Question 8 What is the output of the program shown below? public class Quiz1C { public static void main(String[] args) { int i = 1; StringBuilder s = new StringBuilder("s"); String t = "t"; someMethod(i, s, t); System.out.print("i = " + i + ", "); System.out.print("s = " + s + ", "); System.out.println("t = " + t); } private static void someMethod(int i, StringBuilder s, String t) { i++; s.append("s"); t += "t"; } } Ans) i = 2, s = ss, t = tt
  • 12. Explanation: We are calling the method someMethod(int i, StringBuilder s, String t) by passing the int variable,references of StringBuilder and String Inside that i value will be incremented by 1 Appending s to the content of StringBuilder Object. Concatenating t to the String “t” ______________________________________________________________________ Question 9 Which of the following statements is true about the order of methods in a class. Ans) They can be listed in any order Explanation: We can declare the methods inside the class in any order .there is no restrictions on the order of declaration of methods. ______________________________________________________________________ Question 10 Which of the following statements about constructors is true? Ans) A default constructor is provided automatically if no constructors are explicitly declared in the class Explanation: If we didnt provided any constructor in a class,the java compiler will provide the code for default constructor inside the class while compiling the class. ______________________________________________________________________ Question 11 Which of the following is true about the program shown below? class Quiz1D { private int x; public Quiz1D(int x) { this.x = x; } } Ans) If the this qualifier is removed, it will compile but won't initialize the instance variable Explanation:
  • 13. This refers to the current class instance variable.Even If we didn’t provide ‘this’ also our program will compile but the instance variable will not get initialized.So the instance variable will be initialized with the default value. ______________________________________________________________________ Question 12 Which of the following statements about local variables is true? Ans) A compilation error results when a local variable is accessed before it is initialized. Explanation: Even if we didn’t initialize the during compilation instance variables will be initialized with their default values. But if we want to use local variables compulsory we have to initialize it.If not we will get compilation error. ______________________________________________________________________ Question 13 Analyze the code shown below and indicate which of the following is true: class Quiz1E { private double variable; public Quiz1E(double variable) { variable = variable; } } Ans) The program will compile, but you cannot create an object of Quiz1E with a specified value for variable Explanation: As we didn’t provide ‘this’ so the variable will not get initialized. We wont get any compilation error.But the instance variable value of Quiz1E class will be initialized with the default values by the java compiler.So as it is double data type it will be initialized with 0.0 ______________________________________________________________________ Question 14 Which of the following is true of public methods?
  • 14. Ans) They can only be accessed by methods in a different package Explanation: The scope of the public access specifier is global.So we can access public methods from anywhere like with in the class or from with in the package or from outside the package. ______________________________________________________________________ Question 15 Which of the following statements is true about an immutable object? Ans) The contents of an immutable object cannot be modified Explanation: Immutable: the state or contents of an object cannot be changed or modified.best example for this is String class .We cannot change the contents of the String class Object contents. ______________________________________________________________________ Question 16 What is the output of the program shown below? public class Quiz1F { private static int i = 0; public static void main(String[] args) { { int i = 3; } System.out.println("i is " + i); } } Ans) i is 0 Explanation: The scope of the local variable is confined only to the method itself in which it has been declared. So if we print ‘i’ 0 will be displayed as output.which is the value of the static variable i.as we declared private static int i = 0; ______________________________________________________________________ Question 17
  • 15. Which of the following statements is true of the reserved word this? Ans) It can be only used in instance methods and constructors Explanation: This refer to the current class instance variables.We can use ‘this’ to initialize the instance variables. ______________________________________________________________________ Question 18 Which of the following statements is true about the class shown below? public class Quiz1G { private void method() { } public static void main(String[] args) { method(); } } Ans) It won't compile because method needs to be static Explanation: First the program wont compile.because we didn’t declare that method as static.To solve the error we have to declare the method as static. privatestaticvoid method() { System.out.println("x"); } ______________________________________________________________________ Question 19 Which of the following statements is true of private instance variables? Ans) They can accessed in any instance method in the same class Explanation: The scope of the private is confined to the class itself.We can access the private variables only with in the class in which they have been declared.We can access private instance variables in any method of the same class.
  • 16. ______________________________________________________________________ Question 20 Which of the following statements about class (static) variables is correct? Ans) There is only one copy of each class variable that is shared by all instances of the class Explanation: Static variable:Only one copy of static variable is shared by all the instances of the class.if we modified the value of static variable in one object then it will reflects in other objects of the same class also. ______________________________________________________________