Web Design and Development MCQs with Answers
Practice important Web Design and Development MCQs with answers and explanations.
Chapter: 2
Q21:
Java program code is compiled into form called
A. Machine code
B. Native Code
C. Byte Code
D. Source Code
Correct Answer:
C
Chapter: 2
Q22:
In Java, what must the name of the file match?
A. The main method name
B. The name of the class
C. The name of the JDK
D. The name of the JVM
Correct Answer:
B
Chapter: 2
Q23:
What is the purpose of the Java bytecode verifier?
A. To convert Java code to machine code
B. To ensure bytecodes are valid and secure
C. To compile Java source files
D. To load Java classes into memory
Correct Answer:
B
Chapter: 2
Q24:
Which phase involves writing the Java program using an editor?
A. Edit
B. Compile
C. Load
D. Verify
Correct Answer:
A
Chapter: 2
Q25:
Which phase involves the command java Welcome?
A. Edit
B. Compile
C. Load
D. Execute
Correct Answer:
C
Chapter: 2
Q26:
What does the System.out.println("Hello World"); statement do?
A. Declares a class
B. Compiles the program
C. Prints "Hello World" to the console
D. Loads the program into memory
Correct Answer:
C
Chapter: 2
Q27:
Why is the main method in Java declared static?
A. To allow it to be called without creating an instance
B. To make it private
C. To ensure it returns a value
D. To ensure it is not overridden
Correct Answer:
A
Chapter: 3
Q28:
Which environment variable is modified to permanently set the Java path?
A. JAVA_HOME
B. PATH
C. CLASSPATH
D. JRE_HOME
Correct Answer:
B
Chapter: 3
Q29:
Which of these are valid declarations for the main method?
A. public void main();
B. public static void main(String args[]);
C. static public void main(String);
D. public static int main(String args[]);
Correct Answer:
B
Chapter: 3
Q30:
What is the purpose of the + operator in Java?
A. Concatenate strings
B. Subtract integers
C. Multiply numbers
D. Divide numbers
Correct Answer:
A
Chapter: 3
Q31:
How does Java handle string concatenation with integers?
A. Converts integer to string
B. Adds integers
C. Multiplies integers
D. Subtracts integers
Correct Answer:
A
Chapter: 3
Q32:
Which method is used for comparing the values of two strings in Java?
A. == operator
B. equals method
C. compareTo method
D. compare method
Correct Answer:
B
Chapter: 3
Q33:
In the StringTest class, what is the result of System.out.println("Hello" + i); where i is 4?
A. Hello4
B. Hello
C. 4
D. 9
Correct Answer:
A
Chapter: 3
Q34:
In Java, what does the args array contain when using command-line arguments?
A. Integer values
B. String values
C. Float values
D. Boolean values
Correct Answer:
B
Chapter: 3
Q35:
How do you access command-line arguments in Java?
A. Using args.length
B. Using args[0] and args[1]
C. Using args.size()
D. Using args[1] and args[2]
Correct Answer:
B
Chapter: 3
Q36:
What is the type of the args array in command-line arguments?
A. Integer
B. String
C. Boolean
D. Object
Correct Answer:
B
Chapter: 3
Q37:
How can you convert a String to an int in Java?
A. Integer.parseInt(value)
B. Double.parseDouble(value)
C. Float.parseFloat(value)
D. Boolean.parseBoolean(value)
Correct Answer:
A
Chapter: 3
Q38:
What is the primary difference between primitive data types and objects in Java?
A. Primitive types are on the stack, objects on the heap
B. Objects are on the stack, primitive types on the heap
C. Both are on the stack
D. Both are on the heap
Correct Answer:
A
Chapter: 3
Q39:
Which of the following is not a primitive data type in Java?
A. byte
B. Integer
C. float
D. char
Correct Answer:
B
Chapter: 3
Q40:
How do wrapper classes help in Java?
A. Convert primitive types to objects
B. Increase memory usage
C. Slow down execution
D. Decrease precision
Correct Answer:
A