Web Services Development MCQs with Answers
Practice important Web Services Development MCQs with answers and explanations.
Chapter: 7
Q181:
Which component is NOT part of a method declaration in Java?
A. Modifiers
B. Return type
C. Method name
D. Constructor
Correct Answer:
D
Chapter: 7
Q182:
When a method does not take any parameters, what should be included in the parentheses?
A. The return type
B. The method name
C. Empty parentheses
D. A semicolon
Correct Answer:
C
Chapter: 7
Q183:
What is the access control level of the variable 'format' in the Logger class?
A. Public
B. Protected
C. Private
D. Default
Correct Answer:
C
Chapter: 7
Q184:
Which access modifier allows a class to be accessible from any other class?
A. Private
B. Public
C. Protected
D. Default
Correct Answer:
B
Chapter: 7
Q185:
Which method is necessary to be public in a Java application?
A. main()
B. getFormat()
C. setFormat()
D. Logger()
Correct Answer:
A
Chapter: 7
Q186:
What does the 'void' keyword indicate in a method definition?
A. Returns a value
B. Returns nothing
C. Returns an object
D. Throws an exception
Correct Answer:
B
Chapter: 7
Q187:
What is the term for the value between the round brackets of a method header?
A. Field
B. Local Variable
C. Parameter
D. Argument
Correct Answer:
C
Chapter: 7
Q188:
What happens to a parameter variable after the method call?
A. It is destroyed
B. It becomes a field variable
C. It becomes global
D. It remains accessible
Correct Answer:
A
Chapter: 7
Q189:
Which statement about local variables in Java is true?
A. They have a default value
B. They must be initialized
C. They can have access modifiers
D. They are global
Correct Answer:
B
Chapter: 7
Q190:
What is a field variable in Java?
A. A variable inside a method
B. A global variable
C. A variable outside of methods
D. A constant
Correct Answer:
C
Chapter: 7
Q191:
Which method type is used to modify the state of an object in Java?
A. Accessor
B. Mutator
C. Selector
D. Utility Method
Correct Answer:
B
Chapter: 7
Q192:
What type of method in Java reads the state of an object without changing it?
A. Mutator
B. Utility Method
C. Selector
D. Constructor
Correct Answer:
C
Chapter: 7
Q193:
Which of the following is an example of a method that returns a value?
A. public void setWidth(int newWidth)
B. public int getWidth()
C. public void setOrigin(int x, int y)
D. public void setFormat(String format)
Correct Answer:
B
Chapter: 7
Q194:
Which method in Java would not run the statement after the return statement?
A. public int getWidth() { return width; }
B. public void setWidth(int w)
C. public void setFormat(String f)
D. public void pupAge()
Correct Answer:
A
Chapter: 7
Q195:
What is the scope of a local variable in Java?
A. Global
B. Method
C. Class
D. Package
Correct Answer:
B
Chapter: 7
Q196:
Which of the following methods would be considered a mutator?
A. isOn()
B. getFormat()
C. setWidth()
D. toString()
Correct Answer:
C
Chapter: 7
Q197:
In Java, which type of variable cannot have a static access modifier?
A. Field
B. Instance
C. Local
D. Global
Correct Answer:
C
Chapter: 7
Q198:
Which method in Java is typically private and used by other methods to implement class behavior?
A. Constructor
B. Mutator
C. Utility Method
D. Selector
Correct Answer:
C
Chapter: 7
Q199:
What is the output of the following code: public void pupAge(){ int age = 0; age = age + 7; System.out.println("Puppy age is : " + age); }
A. Puppy age is: 0
B. Puppy age is: 7
C. Puppy age is: 14
D. Puppy age is: 10
Correct Answer:
B
Chapter: 7
Q200:
What does the term "pass-by-value" mean in Java?
A. The actual object is passed
B. A reference to the object is passed
C. A copy of the argument value is passed
D. The argument value is modified directly
Correct Answer:
C