CORE JAVA TEST 6 assesses knowledge in Java file handling, exception management, and object serialization. It evaluates the ability to handle files, manage exceptions, and understand Java's I\/O system, crucial for Java developers.
A.It prints an empty string “”.
B.It prints null.
C.A NullPointerException is thrown at runtime.
D.Compilation fails.
Rate this question:
A.A file fun.log is created with the content “Hello!”.
B.A file fun.log is created but it’s empty, because flush() was not called.
C.A runtime exception is thrown because flush() was not called.
D.Compilation fails.
Rate this question:
A.Compilation fails because a PrintWriter cannot accept a PrintWriter in its constructor.
B.Compilation fails because there is no method print().
C.Two files yo.txt with the same content are created.
D.A file yo.txt with the content “yo” is created.
Rate this question:
A.InputStream
B.PrintStream
C.Reader
D.FileInputStream
FileWriter
Rate this question:
A.pc
B.pcc
C.pcp
D.pcpc
E.Compilation fails
F.An exception is thrown at runtime
Rate this question:
A).e1
B).e2
C)=s
D)fly
E)none of the above
F)compilation fails
G)run time exception
Rate this question:
A.Car
B.Ford
C.Dodge
D.Wheels
E.Vehicle
Rate this question:
A.0
B.3
C.4
D.8
E.9
F.compailation fails
Rate this question:
A.1 2
B.1 2 3 45 6
C.1 2 3 4 5 6
D.1 2 a 3 45 6
E.compilation fails
F.1 2 followed by an exception
Rate this question:
A.FileReader
B.FileWriter
C.FileInputStream
D.FileOutputStream
Rate this question:
A.A file apa is created with content “apa”.
B.A file apa is created with content “apaapa”.
C.Two files are created.
D.An exception is thrown at runtime.
Rate this question:
A.True
B.False
Rate this question:
A.The thread that has been waiting the longest.
B.The thread that was the last one to to exit the monitor.
C.You can never be sure which thread will get to run first.
D.The the first thread that called the wait() method
Rate this question:
A.public Thread(Object obj)x
B.public Thread(String name)
C.public Thread(Runnable trgt)
D.public Thread(ThreadGroup grp, Runnable trgt, String name)
E.public Thread(ThreadGroup grp, Object ob)
Rate this question:
A.True
B.False
Rate this question:
A.public void run()
B.public void start()
C.public void exit()
D.public final void setAccess()
E.public final void setPriority(int priNbr)
F.public final int getPriority()
Rate this question:
A.True
B.False
Rate this question:
A).run-test run-test
B).run-test
C)Compilation fails due to an error on line 4
D)Compilation fails due to an error on line 7
Rate this question:
A.run-a
B.run-a run-a
C.Compilation fails with an error at line 6
D.Compilation succeed but Runtime Exception
Rate this question:
A.A A A A B B B B
B.A B A B A B A B
C.Output order is not guaranteed
D.Compilation succeed but Runtime Exception
Rate this question:
A.waiting run 1225
B.waiting run 0
C.waiting run and count can be anything
D.Compilation fails
Rate this question:
A.0 0
B.Compilation error, class A has no start method
C.0 1
D.Compilation succeed but runtime exception
Rate this question:
A.public class MyRunnable extends Runnable{public void run(){}}
B.public class MyRunnable extends Object{public void run(){}}
C.public class MyRunnable implements Runnable{public void run(){}}
D.public class MyRunnable implements Runnable{void run(){}}
E.public class MyRunnable implements Runnable{public void start(){}}
Rate this question:
Public int read(){return a+b;} a.public void set(int a, int b){this.a=a;this.b=b;}
Public synchronized int read(){return a+b;} b.public synchronized void set(int a, int b){this.a=a;this.b=b;}
C.public int read(){synchronized(a){return a+b;}} public void set(int a, int b){synchronized(a){this.a=a;this.b=b;}}
Public int read(){synchronized(a){return a+b;}} public void set(int a, int b){synchronized(b){this.a=a;d.this.b=b;}}
Public synchronized(this) int read(){return a+b;} public synchronized(this) void set(int a, int b){this.a=a;e.this.b=b;}
Public int read(){synchronized(this){return a+b;}} public void set(int a, int b){synchronized(this){this.a=a;f.this.b=b;}}
Rate this question:
It fails to compile because the IllegalMonitorStateException of wait() is not dealt a.with in line 7
B.2 3
C.1 3
D.1 2
At runtime, it throws an IllegalMonitorStateException when e.trying to wait
It will fail to compile because it has to be synchronized on the f.this object
Rate this question:
A.After object B is notified, or after two seconds
B.After the lock on B is released, or after two seconds
C.Two seconds after object B is notified
D.Two seconds after lock B is released
Rate this question:
A.The notifyAll() method must be called from a synchronized context
B.To call wait(), an object must own the lock on the thread
C.The notify() method is defined in class java.lang.Thread
When a thread is waiting as a result of wait(), it releases its d.lock
The notify() method causes a thread to immediately release its e.lock
The difference between notify() and notifyAll() is that notifyAll() notifies all f.waiting threads, regardless of the object they're waiting on
Rate this question:
A.This class is already thread-safe
Replacing StringBuilder with StringBuffer will make this class b.thread-safe
C.Synchronize the log() method only
D.Synchronize the getContents() method only
E.Synchronize both log() and getContents()
F.This class cannot be made thread-safe
Rate this question:
A.It prints X and exits
B.It prints X and never exits
C.It prints XY and exits almost immeditately
D.It prints XY with a 10-second delay between X and Y
E.The code does not compile
F.An exception is thrown at runtime
Rate this question:
A compile time error indicating that no run method is defined a.for the Thread class
A run time error indicating that no run method is defined for b.the Thread class
C.Clean compile and at run time the values 0 to 9 are printed out
D.Clean compile but no output at runtime
Rate this question:
A.good
B.good idea
C.good idea good idea
D.good 0 good 0 1
Rate this question:
A.Compile error
B.One One Two Two
C.One Two One Two
D.One Two
Rate this question:
A.t t1
B.t1 t
C.t t
D.Compilation succeed but Runtime Exception
Rate this question:
A.good
B.null
C.Compilation fails with an error at line 5
D.Compilation succeed but Runtime Exception
Rate this question:
A.MIN_PRIORITY (which is defined as 1 in the Thread class.)
B.NORM_PRIORITY (which is defined as 5 in the Thread class.)
C.MAX_PRIORITY (which is defined as 10 in the Thread class.)
D.A thread inherits the priority of its parent thread
Rate this question:
A.The run() method should be directly invoked on the Object.
B.The start() method should be directly invoked on the Object.
C.The init() method should be directly invoked on the Object.
The creation of the object using the new operator would create a d.new thread and invoke its run() method.
Rate this question:
The wait method defined in the Thread class, can be used to a.convert a thread from Running state to Waiting state
The wait(), notify(), and notifyAll() methods must be executed b.in synchronized code.
The notify() and notifyAll() methods can be used to signal and c.move waiting threads to ready-to-run state.
D.The Thread class is an abstract class.
Rate this question:
A.public static void sleep(long millis, int nanos)
B.public static native void sleep(long millis, int nanos)
C.public static native void sleep(long millis)
D.public static void sleep(long millis)
Rate this question:
A.A running thread will be placed in suspended state.
B.A running thread will be placed in sleeping state.
C.A running thread will be placed in ready state.
D.Neither of the above.
Rate this question:
Quiz Review Timeline (Updated): Mar 21, 2023 +
Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.
Wait!
Here's an interesting quiz for you.