If we have a 2D array int[][] arr, the expression arr[i] refers to the __________.

  • an error
  • entire array
  • ith column of the array
  • ith row of the array
In a 2D array in Java, arr[i] refers to the ith row of the array. This is because a 2D array is essentially an array of arrays, where each element arr[i] is itself an array representing a row. Accessing arr[i] gives you the entire row at index i.

The expression a != b returns true if a is ______ b.

  • equal to
  • greater than
  • less than
  • not equal to
The expression "a != b" returns true if "a" is not equal to "b." It checks if the values of "a" and "b" are different. The "!=" operator is used for inequality comparisons. The other options represent different comparison operations.

Imagine a situation where you are dealing with very large files that need to be read and processed, but you want to ensure that the system remains responsive and does not run out of memory. How would you implement file reading in this case?

  • Read the entire file into memory using FileInputStream.
  • Use a BufferedReader with a small buffer size.
  • Implement a memory-mapped file using FileChannel and MappedByteBuffer.
  • Use Scanner with a large buffer size.
To ensure responsiveness and prevent memory exhaustion when dealing with large files, it's best to use a BufferedReader with a reasonably small buffer size. This allows for efficient reading of the file without loading the entire content into memory. The other options are less efficient and may lead to memory issues.

What method is commonly used to execute SQL queries in Java?

  • execute()
  • executeQuery()
  • executeStatement()
  • executeUpdate()
In Java, the executeQuery() method is commonly used to execute SQL queries using JDBC. This method is specifically designed for executing SELECT queries and returns a ResultSet containing the query results. The other options (executeStatement(), executeUpdate(), and execute()) are not typically used for executing queries or have different purposes.

You are developing a real-time gaming application where certain operations need to be repeated at regular time intervals. Which looping mechanism and timing control statements would you use to achieve this without blocking the user interface?

  • do-while loop and Thread.yield()
  • for loop and System.nanoTime()
  • forEach loop and System.currentTimeMillis()
  • while loop and Thread.sleep()
In a real-time gaming application, you would typically use a while loop in combination with the Thread.sleep() method to introduce a delay between iterations without blocking the UI. The other options may not be suitable for achieving this specific timing control.

How does the FileWriter class handle character encoding?

  • It always uses the system's default character encoding.
  • It automatically detects and sets the appropriate character encoding.
  • It doesn't support character encoding; it writes bytes as is.
  • It prompts the user to choose the encoding when creating an instance.
The FileWriter class in Java uses the system's default character encoding for writing text to a file. It doesn't automatically detect or set character encoding. To specify a different encoding, you should use constructors like FileWriter(String fileName, Charset charset) to explicitly set the encoding.

The primary purpose of functions in SASS is to ________.

  • Calculate mathematical expressions
  • Create loops
  • Define variables
  • Group CSS properties
The primary purpose of functions in SASS is to calculate mathematical expressions. SASS functions can perform various mathematical operations, making it easy to compute values for CSS properties dynamically. They are valuable for maintaining consistency and making stylesheets more maintainable.

While using a CSS preprocessor, you notice that the compiled CSS has selectors that are excessively long and specific. What might be a potential cause for this in your source files?

  • Overuse of nesting in SASS or LESS
  • Lack of CSS optimization tools
  • Errors in the preprocessor settings
  • Incorrect order of imported stylesheets
Excessively long and specific selectors in compiled CSS are often caused by overusing nesting in preprocessors like SASS or LESS. While nesting can improve code organization, it can also lead to overly specific selectors that increase file size and reduce maintainability.

Which modular CSS methodology uses the Block, Element, Modifier structure?

  • BEM (Block, Element, Modifier)
  • ITCSS (Inverted Triangle CSS)
  • OOCSS (Object-Oriented CSS)
  • SMACSS (Scalable and Modular Architecture for CSS)
The modular CSS methodology that uses the Block, Element, Modifier structure is BEM, which stands for Block, Element, Modifier. BEM is a naming convention that helps create maintainable and predictable CSS code by organizing styles into blocks, elements, and modifiers.

When using the "vertical-align" property, what does the value "baseline" represent?

  • Aligns elements to the baseline of the parent element
  • Aligns elements to the bottom of the line box
  • Aligns elements to the middle of the line box
  • Aligns elements to the top of the line box
In CSS, the "vertical-align" property is used to control the vertical alignment of inline or inline-block elements within a line box. When set to "baseline," it aligns elements to the baseline of their parent element, which is typically the bottom of the characters within the text.

The ________ combinator in CSS targets elements that are placed immediately after a specific element.

  • + (Adjacent Sibling)
  • , (Comma)
  • > (Child)
  • ~ (General Sibling)
The "+" (Adjacent Sibling) combinator in CSS targets elements that are placed immediately after a specific element. It selects elements that share the same parent and are placed directly after the specified element.

In Flexbox, which property is used to define how items are aligned along the main axis?

  • align-content
  • align-items
  • flex-direction
  • justify-content
In Flexbox, the justify-content property is used to define how items are aligned along the main axis. It controls the distribution of space between and around items along the main axis and is commonly used to center items horizontally or vertically.