The ________ method of DatagramSocket class is used to send a packet to a server.

  • send()
  • sendPacket()
  • sendToServer()
  • transmitPacket()
In Java, the send() method of the DatagramSocket class is used to send a packet to a server. It is a crucial method for working with UDP (User Datagram Protocol) sockets.

What will be the output of the following code snippet: public int add(int a, long b) { return a + b; } and public long add(int a, int b) { return a + b; }?

  • Compilation Error: Ambiguous method call.
  • Compilation Error: Duplicate method add with the same parameter types.
  • Compilation Error: Mismatched return types.
  • The code will run without errors, and the output will be the sum of a and b.
The code will result in a compilation error because both methods have the same name and the same parameter types (int and long). Java does not allow you to overload methods based solely on the return type. Overloaded methods must have different parameter lists. Overloading based on return types would lead to ambiguity.

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.

What will be the initial capacity of a HashSet when no size is defined during its creation?

  • 0
  • 10
  • 16
  • It will result in an error
When you create a HashSet in Java without specifying its initial capacity, it defaults to an initial capacity of 16. The capacity dynamically increases as needed when elements are added to the HashSet.

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.

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.

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.

To create a shadow effect behind an element, you'd use the ________ filter.

  • blur
  • drop-shadow
  • glow
  • shadow
To create a shadow effect behind an element in CSS, you'd use the drop-shadow filter. This filter adds a shadow to an element, allowing you to control its position, color, and blur.

What is the main purpose of media queries in CSS?

  • To add multimedia elements like images and videos
  • To apply different styles based on user interactions
  • To change the color scheme of a webpage
  • To modify the layout and design of a webpage based on the device's characteristics, such as screen size and orientation
Media queries in CSS are primarily used for creating responsive web design. They allow web developers to adapt the layout and styling of a webpage based on the characteristics of the device, such as screen width, height, and orientation. This is essential for ensuring a consistent and user-friendly experience across various devices, from desktops to mobile phones.

If you want an animation to alternate between running forwards and backwards, you would use the animation-direction value of ______.

  • alternate
  • alternate-reverse
  • repeat
  • reverse
To make an animation alternate between running forwards and then backwards, you would use the value alternate for the animation-direction property. This creates a back-and-forth effect for the animation, making it appear as if it's reversing after each cycle.