Font size
WorksheetsMIDTERM ITC-103
Total questions: 50
Worksheet time: 48mins
Defining Java Methods: What is the purpose of a return type in a Java method?
It specifies the type of value that the method will return.
It controls the visibility of the method.
It specifies the name of the method.
It determines the number of parameters the method can accept.
Defining Java Methods: What is a method in Java?
A method in Java is a block of code that performs a specific task and is defined within a class.
A method in Java is a type of data structure
A method in Java is a type of variable
A method in Java is a form of loop
Passing parameters to Java Methods: What are parameters in Java methods?
Containers used to store the method's code
Reserved keywords used to define the method's behavior
Special characters used to indicate the method's return type
Variables used to pass values to the method
Passing parameters to Java Methods: Explain the process of passing parameters to a Java method.
You declare the parameters within the parentheses of the method declaration and provide the actual values when calling the method.
You declare the parameters after the method declaration
You declare the parameters within the body of the method
You declare the parameters in a separate file
Method overloading in Java: What is method overloading in Java?
When a class has multiple methods with the same name but different parameters.
When a class has only one method with different parameters
When a class has no methods with the same name
When a class has multiple methods with the same name and same parameters
Method overloading in Java: What are the rules for method overloading in Java?
The return type must always be different
The rules for method overloading in Java are that the methods must have the same name but different parameters, and the return type may or may not be different.
The methods must have the same name and the same parameters
The methods must have different names and different parameters
What is the return type of a method that does not return any value?
int
float
void
double
"void" and "return" can not be used together?
True
False
In this framework, all real-world entities are represented by Classes.
Functional Programming
Logical Programming
Object-Oriented Programming
Procedural Programming
Which of the following creates an object of Main class?
Main obj = new Main;
Main obj = new Main();
Main obj = new Mian();
Main obj == new Main();
Which of the following is the complete syntax of creating a class?
public class Main { }
public class Main() { }
public class Main
public class Main()
Another term for variable within a class
(a)
Methods are declared within a class.
True
False
static void myMethod(){ }
What is the name of the method?
static void myMethod
void myMethod
static myMethod
myMethod
Which of the following statements calls a method greetings and pass a value to that method?
greetings();
greeting("Hello, world!");
greetings("Hello, world!");
greetings(Hello, world!);
Which modifiers makes a method accessible without creating an object of the class?
static
public
Write a line of code in java that creates a method studentName that can be accessed using an object. (Parameters and return are not needed)
(a)
Write a line of code in java that declares an attribute age that has a value of 15.
(a)
Which of the following line of codes calls an attribute x within a class, and prints its value?
System.out.println(x());
System.out.println(x);
System.out.println(obj.x)
System.out.println("x");
Which modifier for classes make a class accessible only by classes in the same package?
private
public
default
static
What modifier makes an attribute accessible within the declared class only?
(a)
What modifier makes an attribute and methods cannot be overridden/modified?
(a)
Which component is used to compile,debug and execute the java programs ?
JRE
JIT
JDK
JVM
Which of these are selection statements in java
Break
Continue
For ( )
If ( )
Which one of the following is not an access modifier ?
Protected
Void
Public
Private
It is an access specifier.
Public
Void
Main
Static
____ keyword acknowledges the compiler that main() method does not return any value.
Public
Void
Main
Static
You can make a method static by using the keyword _______.
Public
Void
Main
Static
What is the return type of the main() method?
(a)
The keyword "method" is another name for
an object
a class
a function
a variable
Which of the following is NOT a numeric data type
int
double
float
decimal
Which of the following is incorrect?
int count = 50.0;
int salary = 50_000;
int salary = 50_00;
all of these are incorrect
Where does a java program start executing instructions from:
class
source file
main method
object
Consider the following code segment:
int count = 5;
double multiplier = 2.5;
int answer = (int)(count * multiplier);
answer = (answer * count) % 10;
System.out.println(answer);
What is printed as a result of executing the code segment?
0
2.5
6
12.5
60
What is an instance of or a copy of a class?
Class
Object
Attribute
Interface
Which one(s) is/are an object?
public class Rectangle
Student ada = new Student();
Rectangle rect = new Rectangle(10, 3);
ada.reName();
What is move in the following:
p1.move(2,4);
Class
Object
Method
Instance
EVERY Java program MUST have these 2 essential parts in order to even RUN:
a public class and the main() method
a private class and the main() method
a public class and at least one object
a private class and at least one object
In OOP the main importance is given to the
methods
procdures
data
objects
What is the default value of a primitive int data type?
-1
null
0
garbage data
In Java, a single-line comment starts with "/*".
TRUE
FALSE
