0% found this document useful (0 votes)
38 views5 pages

STS3401

Uploaded by

sarahloner030
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views5 pages

STS3401

Uploaded by

sarahloner030
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Name:

Reg no:
INTERNAL ASSESSMENT -2 DATE: //
Venue:
FALL SEMESTER 2023-24
Qualitative Skills Practice I Code : STS3401
Course Title :
SET : A
Faculty (s) : SIX PHRASE Slot :
Time : 30 mins Max. Marks : 30
Answer all the Questions
S. No QUESTIONS Marks
1. What is the main difference between StringBuffer and StringBuilder? 1

A) StringBuffer is synchronized, StringBuilder is not


B) Either is synchronized
C) Both are synchronized
D) Neither is synchronized
2. What is the output of the following code snippet? 1
public class Main {
public static void main(String[] args) {
int x = 10;
if (x > 5) {
System.out.println("Hello");
} else {
System.out.println("World");
}
}
}

A) Hello World B) World C) Hello D) Error


3. What is the purpose of jumping statements in Java? 1
A) To perform arithmetic operations B) To alter the flow of control in a program

C) To handle exceptions D) To make decisions based on conditions


4. What is the purpose of the StringBuilder class in Java? 1
A) To create numeric strings B) To create immutable strings

C) To create mutable strings D) To create boolean strings


5. What is the root class of all Java classes? 1
A) Root B) Class C) Java D) Object
6. How does the break statement affect the switch statement? 1
A) It terminates the switch statement prematurely
B) It skips the current case and proceeds to the next
C) It restarts the switch statement from the beginning
D) It has no impact
7. What does it mean for a string to be immutable? 1
A) It cannot be compared with other strings B) It can be changed after creation
C) It can only be used once D) It cannot be changed after creation
8. What is the sum of the proper divisors of 28? 1
A) 1 B) 14 C) 28 D) 7
9. Which class is used for reading input from the command line in Java? 1

A) BufferedWriter B) BufferedReader C) Scanner D) System


10. Which of the following is a valid identifier in Java? 1
A)class B) 123variable C) #variable D) myVariable
11. How is a password read securely in Java? 1

A) By using the Scanner class B) By using the BufferedReader class

C) By using the Console class D) By using the BufferedWriter class


12. How is a static nested class different from an inner class? 1

A) It has access to the instance variables of the outer class


B) It doesn't have access to the instance variables of the outer class
C) It is defined within a method
D) It cannot access any class members
13. What does the following code snippet do? 1

public class Main {


public static void main(String[] args) {
int x = 5;
switch (x) {
case 1:
System.out.println("One");
break;
case 5:
System.out.println("Five");
break;
case 10:
System.out.println("Ten");
break;
default:
System.out.println("Default");
}}}

A) Prints "One" B) Prints "Ten" C) Prints "Five" D) Prints "Default"


14. What is a strong number?
A) A number that is the sum of its digits raised to the power of their position
B) A number that is the product of two equal factors
C) A number that is equal to the sum of its proper divisors
D) A number whose sum of factorials of its digits is equal to the number itself
15. What is the significance of program structure in software development?

A) It complicates the code B) It enhances readability, maintainability, and scalability

C) It decreases efficiency D It has no impact


16. How can you check if two objects refer to the same memory address?

A) By using the equals() method B) By using the getClass() method

C) By using the hashCode() method D) By using the == operator

17. What does modular programming emphasize? 1

A) Reducing code reuse B) Breaking down programs into smaller, manageable modules

C) Ignoring code organization D) Writing lengthy, monolithic code


15. What happens if a non-abstract subclass doesn't implement all the abstract methods of its abstract 1
superclass?
A) The subclass must also be declared abstract
B) The subclass must override all abstract methods
C) The subclass cannot be instantiated
D) The subclass inherits the abstract methods

16. What is a member inner class? 1


A) A class defined within another class at the member level
B) A class defined within a package
C) A class defined within an interface
D) A class defined within a method

17. What is the advantage of using StringBuilder over StringBuffer? 1


A) Better concurrency control B) Better error handling
C) Better memory management D) Better performance due to lack of synchronization

18. How are BufferedReader objects created in Java? 1


A) By using the new keyword followed by the class name
B) By wrapping input streams such as System.in
C) By invoking methods like readLine()
D) By using the print() method

19. How can you convert other data types to strings in Java? 1
A) By using the parse() method
B) By using the format() method
C) By using the toString() method
D) By using the valueOf() method

20. How does inheritance contribute to code reuse in Java? 1


A) By allowing a class to inherit fields and methods from another class
B) By preventing code reuse
C) By increasing code complexity
D) By limiting code flexibility

21. What does the bitwise NOT operator (~) do? 1


A) Performs a bitwise XOR operation
B) Performs a bitwise AND operation
C) Performs a bitwise OR operation
D) Flips the bits of its operand

22. What happens if you exceed the capacity of a StringBuilder object? 1


A) It automatically increases its capacity
B) It throws an exception
C) It decreases its capacity
D) It remains unchanged

23. What is the purpose of the hashCode() method in Java? 1


A) To return the memory address of an object
B) To compare two objects
C) To return the hash code value of an object
D) To create a new object

24. When is the return statement used in a void method? 1


A) To return a value to the calling method
B) To restart the method from the beginning
C) To terminate the program immediately
D) To exit the method without returning a value

25. What is the purpose of making a class abstract? 1


A) To define a common interface for subclasses
B) To prevent instantiation of the class
C) To simplify code
D) To increase code complexity

26. How is input read from the console using the Scanner class? 1
A) By using the write() method
B) By invoking methods like nextInt() or nextLine()
C) By using the read() method
D) By using the print() method

27. What is a local inner class in Java? 1


A) A class defined within a method
B) A class defined within another class
C) A class defined within a package
D) A class defined within an interface

28. What is an object in object-oriented programming? 1


A) A data type
B) A blueprint for creating classes
C) A function
D) An instance of a class

29. What does the indexOf() method in java return? 1


a) The index of the first occurrence of a specified substring
b) The index of the last occurrence of a specified substring
c) The length of the string
d) The number of occurrence of a specified character

30. How does using appropriate identifiers and data types enhance code quality? 1
a) It improves readability, maintainability and reduces error
b) It increases the errors and decreases the readability
c) It has no impact on the code quality
d) It slows down execution.

You might also like