CSCI 201L MT Quizzes

A colorful and engaging illustration of computer code, with Java-related icons like a coffee cup, a JVM logo, and various programming symbols, set in a modern and techy atmosphere.

Java Programming Knowledge Quiz

Test your knowledge of Java programming concepts with this engaging quiz designed for both beginners and experienced developers. This quiz covers a variety of topics including object-oriented programming, concurrency, exception handling, and more!

Here’s what you can expect:

  • 37 challenging questions
  • Multiple-choice format
  • Instant feedback on your answers
  • Improve your Java skills
37 Questions9 MinutesCreated by CodingNinja47
Where are files stored in a computer system?
Non-volatile memory
Cache
Main memory
Volatile memory
How are Java objects allocated?
Java gives the programmer the ability to allocate objects either dynamically or statically.
All Java objects are dynamically allocated.
All java objects are statically allocated.
Java doesn't have objects, just primitive variable types.
What is the motto of Java?
Better than C++
Run once, write anywhere
Platform-indepenent
Write once, run anywhere.
What type of inheritance does Java support?
Hierarchical
Multiple
Java does not support inheritance
Single
When a method is called on an instance of a derived class, which definition of the method is called?
The method from the runtime type class.
The method from the derived class
There will be an error since you can't define a function twice.
The method from the base class.
Which of the following statements regarding interfaces is correct?
An interface contains method implementations.
A class can only implement a single interface.
Both option #1 and option #2
Neither option #1 nor option #2
A class is encapsulated if:
All data is declared public
All data is declared private
At least one variable is declared public
At least one variable is declared private
What is the difference between checked and unchecked exceptions?
Unchecked exceptions may or may not be handled in a try-catch block, and checked exceptions must be handled in a try-catch block.
Unchecked exceptions are handled in a try-catch block, and checked exceptions are not.
Unchecked exceptions may or may be not handled in a try-catch block, and checked exceptions must be handled in a try-catch block.
Unchecked exceptions may or may not be handled in a try-catch block, and checked exceptions are not handled in a try-catch block.
Which of the following must be handled in a try-catch block?
NoClassDefFoundError
IOException
NullPointerException
All of the above
Which one of the following statements is true about Java's Serializable interface?
Static and private variables of an object are not saved when an object implements the Serializable interface
An object can be stored using an ObjectOutputStream and retrieved using an ObjectInputStream when the object's class implements the Serializable interface
An object's state cannot be retrieved when the object's class implements the Serializable interface
An object can be stored using an ObjectInputStream and retrieved using an ObjectOutputStream when the object's class implements the Serializable interface.
Which of the following statements regarding Garbage Collection in Java is true?
A memory location is a candidate for garbage collection when it no longer is referenced by any part of your program.
Programmers can explicitly invoke the garbage collector by calling "System.gc()"
The programmer can explicitly free memory by calling the "free()" and "delete()" methods
None of the above
Can you invoke the garbage collector to run immediately?
No, we can make suggestions to the JVM to run it as soon as possible by calling System.gc()
Yes, by calling delete()
Yes, by calling System.gc()
Java does not have a garbage collector
If a thread cannot acquire the monitor on a synchronized block of code, to what state does the thread move?
Dead
Waiting
Ready
Sleeping
Which of the following statements about the code is correct?
 

public class ThreadMaker {

 public static void main (String[] args) {

  System.out.print("First Line");

  Thread ta = new Thread(new MyThread("a"));

  Thread tb = new Thread(new MyThread("b"));

  Thread tc = new Thread(new MyThread("c"));

  ta.start();

  tb.start();

  tc.start();

  try {

   ta.join();

   tb.join();

   tc.join();

  } catch (InterruptedException e) {

   System.out.println("e: " + e.getMessage());

  }

  System.out.print("Last Line");

 }

}


class MyThread implements Runnable{

 String name;

 MyThread(String name){

  this.name = name;

 }

 public void run() {

  for (int I = 0; I < 4; i++) {

    System.out.print(name + I + " ");

  }

 }

}

Tb waits for ta to finish before it continues executing
No thread waits for any other thread
Ta waits for tb and tc to finish before it continues executing
The main thread waits for ta, tb, and tc to finish before it continues executing
Which thread method do you want to call if you want to begin a thread's execution?
Yield
Sleep
Run
Start
Extending Thread is a worse idea than implementing Runnable because...
Extending Thread will handicap your ability to inherit from other classes
Extending Thread results in significantly more overhead
Implementing Runnable makes it possible to let a thread start itself
Thread actually cannot be extended, only implemented since it's an interface
When acquiring a monitor on a static synchronized method, the monitor is acquired on what?
The method
The block of code using a shared variable
The instance of the class
The class
What happens if a thread calls await() and doesn't receive a signal?
After a set amount of time, which is passed as a parameter in the await() function, the thread moves out of the waiting state
The thread remains in the waiting state forever
The JVM moves the thread out of the waiting state after a predetermined amount of time
None of the above
What is the correct way to implement the fork/join framework so that we can process asynchronously and return the value?
We recursively use conditional statements to call fork() and join()
We override the run() method after extending Thread or implementing Runnable interface and call execute() on ForkJoinPool
We override the compute() method and call the invoke() method on the ForkJoinPool object
We override the compute() method and call the start() method on the ForkJoinPool object
Why is a performance increase not guaranteed for parallel computing?
Network delays cause performance bottlenecking
Modern-day CPUs have sufficient single-core performance
Forking and joining both have overhead
Parallel computing adds functionality and does not increase performance
Which of the following statements regarding semaphores is correct?
A thread can release permits on a semaphore even without having them
A thread must acquire one of the permits of the semaphore before executing code managed by a semaphore
The number of permits available on a semaphore is specified at creation
All of the above
Does parallelizing code always mean faster execution?
Not always
Parallelizing code does not make execution faster
Yes
Java does not offer parallel programming
In the producer/consumer problem with multiple producers and locks and conditions, why are some data members and methods static?
The static keyword prevents more than one instance of a producer/consumer from modifying data at the same time
The static keyword defines shared resources amongst every instance of a class
The static keyword makes the chosen data members thread safe
None of the above
When does deadlock occur?
When the producer does not wait on a resource from the consumer, but the consumer waits on something from the producer.
When the producer waits on a resource from the consumer, but the consumer is not waiting on something from the producer.
When neither the producer nor the consumer is waiting on a resource from the other.
When both the producer and consumer are waiting on resources from the other.
What is the producer/consumer problem, and why is it important?
Producers withdraw items, consumers insert items, and this is an example of parallel programming.
Producers withdraw items, consumers insert items, and this is an example of concurrent programming.
Producers insert items, consumers withdraw items, and this is an example of parallel programming.
Which of the following are valid ways to correctly simulate the Producer and Consumer problem?
Use the "synchronized" keyword
Use locks and conditions
Both A and B
Neither A nor B
The following function prevents deadlock by signaling to whoever is waiting:
.sleep()
.wait()
.await()
.notify()
Which of the following is NOT true regarding IP addresses:
IP address are not required for a computer to communicate on a network.
IPv4 addresses consist of 32 bits.
IP address is a unique address.
IPv6 addresses consist of 128 bits.
What are some criteria of failed software projects?
Project went over the budget
The final product is missing critical features
The final product is not functional
All of the above
Is 172.21.101.211 a public IP Address or a private IP Address?
Neither
Both
Private
Public
What is a source of failure for software engineering projects?
Not functional or buggy
Missing critical features
Over schedule/budget
All of the above
How many 32 bit IPv4 addresses are there?
Unlimited
One billion
Over four billion
10 billion
Which does a client application need to connect to a server application?
IP Address
Socket
Port
All of the above
How would we create a socket listening on port 6789 of the loopback address?
Socket s = new Socket("127.0.0.1", 6789);
Socket s = new Socket("loopback", 6789);
Socket s = new Socket(6789, "localhost");
Socket s = new Socket(6789, "127.0.0.1");
What’s the purpose of NAT (network address translation)?
It connects the port number to the dns server.
It determines the IP address class.
It solves the problem that ipv6 has run out of available addresses.
It replaces the private ip address with the public IP address on outgoing request.
What type of address is 79.125.0.0?
Class A, Private
Class B, Public
Class A, Public
Class B, Private
What is a socket?
Socket is the combination of the IP address and port number needed by the client.
Socket is the port number of the client and server connection.
Socket is the IP address of the client.
Socket is the IP address of the server.
{"name":"CSCI 201L MT Quizzes", "url":"https://www.quiz-maker.com/QPREVIEW","txt":"Test your knowledge of Java programming concepts with this engaging quiz designed for both beginners and experienced developers. This quiz covers a variety of topics including object-oriented programming, concurrency, exception handling, and more! Here’s what you can expect: 37 challenging questions Multiple-choice format Instant feedback on your answers Improve your Java skills","img":"https:/images/course2.png"}
Powered by: Quiz Maker