Web Services Development MCQs with Answers
Practice important Web Services Development MCQs with answers and explanations.
Chapter: 6
Q161:
To generate a random double between 0.0 and 10.0, which method is used?
A. wheel.nextDouble()
B. wheel.randomDouble()
C. wheel.generateDouble()
D. wheel.createDouble()
Correct Answer:
A
Chapter: 6
Q162:
In a multidimensional array, the _______ method is used to get the upper bound for each dimension.
A. GetUpperBound()
B. GetLowerBound()
C. GetLength()
D. GetSize()
Correct Answer:
A
Chapter: 6
Q163:
Fill in the blank: The _______ operator is used to declare an array reference variable in Java.
A. []
B. ()
C. {}
D. =
Correct Answer:
A
Chapter: 6
Q164:
Fill in the blank: The method used to generate a random number in Java is _______.
A. Random
B. nextInt()
C. nextDouble()
Correct Answer:
A
Chapter: 6
Q165:
Fill in the blank: The statement 'int[] myArray = new int[10];' creates an array with _______ elements.
A. 10
B. 5
C. 20
D. 1
Correct Answer:
A
Chapter: 6
Q166:
Fill in the blank: To access the third element of an array named 'num', we use the syntax _______.
A. num[2]
B. num[3]
C. num[1]
D. num[0]
Correct Answer:
A
Chapter: 7
Q167:
What are templates used to create objects in OOP?
A. Arrays
B. Classes
C. Methods
D. Variables
Correct Answer:
B
Chapter: 7
Q168:
Which of the following is NOT a core property of a class?
A. Data types
B. Methods
C. Interfaces
D. Objects
Correct Answer:
D
Chapter: 7
Q169:
What is passed when using pass-by-value in a method call?
A. A copy of the actual parameter
B. The original parameter
C. A reference to the parameter
D. The method itself
Correct Answer:
A
Chapter: 7
Q170:
What happens to an array when passed as a parameter in Java?
A. A copy is passed
B. The reference is passed
C. The array is duplicated
D. The array is converted to a string
Correct Answer:
B
Chapter: 7
Q171:
Which keyword is used to create an object in Java?
A. create
B. instantiate
C. new
D. object
Correct Answer:
C
Chapter: 7
Q172:
What is the purpose of a constructor in a class?
A. Initialize objects
B. Declare variables
C. Define methods
D. Allocate memory
Correct Answer:
A
Chapter: 7
Q173:
In Java, which of the following is a no-argument constructor?
A. public Class() {}
B. public Class(int x) {}
C. public void Class() {}
D. public Class() int {}
Correct Answer:
A
Chapter: 7
Q174:
When an object is created, what is returned by the 'new' operator?
A. A reference to the object
B. A copy of the object
C. The name of the object
D. The class of the object
Correct Answer:
A
Chapter: 7
Q175:
Which of the following statements is TRUE about reference variables?
A. They store primitive data types
B. They hold the memory address of objects
C. They cannot be null
D. They are initialized automatically
Correct Answer:
B
Chapter: 7
Q176:
Which of the following is required when declaring a method in Java?
A. A return type
B. A class name
C. A field variable
D. An interface
Correct Answer:
A
Chapter: 7
Q177:
Which access modifier is the most restrictive in Java?
A. public
B. protected
C. private
D. default
Correct Answer:
C
Chapter: 7
Q178:
What will be the output if both 'r1' and 'r2' refer to the same Rectangle object and 'r2.length = 20;' is executed after 'r1.length = 10;'?
A. r1.length = 10; r2.length = 20
B. r1.length = 20; r2.length = 10
C. r1.length = 20; r2.length = 20
D. r1.length = 10; r2.length = 10
Correct Answer:
C
Chapter: 7
Q179:
Which keyword is used to declare a method that doesn't return a value?
A. void
B. return
C. null
D. private
Correct Answer:
A
Chapter: 7
Q180:
What does the term "instantiating a class" refer to in Java?
A. Creating an object
B. Declaring a method
C. Defining a variable
D. Implementing an interface
Correct Answer:
A