
java-oop – programming-java – কুইজ মডেল টেস্ট অনুশীলন – 10
java oop | 7834. Which of the following can access private data members or member functions of a class?
- Only public member functions of that class.
- Any function in the program.
- Any member function of that class.
- All global functions in the program.
7835. The .dot operator connects the following two entities :
- a class object and a member of that class
- a class object and a class
- a class and a member of that class
- a class member and a class object
7836. Given: class A { public A(int x){} } class B extends A { } public class test { public static void main (String args []) { A a = new B(); System.out.println(“complete”); } } What happens when you attempt to compile and run this code?
- Compiles but fails at runtime
- Compile Error
- Prints “complete”
- It compiles and runs printing nothing
7837. Given: public class SyncTest { private int x; private int y; private synchronized void setX(int i) {x = 1;} private synchronized void setY(int i) {y = 1;} public void setXY(int i){setX(i); setY(i);} public synchronized Boolean check() {return x != y;} } Under which conditions will check() return true when called from a different class?
- check() can only return true if SyncTest is changed to allow x and y to be set separately.
- check() can return true when setXY() is called by multiple threads.
- check() can never return true.
- check() can return true when multiple threads call setX() and setY() separately.
7838. If we want to prevent the subclass from overriding the member of super class, then we need to declare it as ……….
- all of the above
- static
- final
- abstract
7839. Which of the following access specifies is used in a class definition by default?
- Private
- Protected
- Public
- Friend
7840. Given: public class MyLogger { private StringBuilder logger = new StringBuuilder(); public void log(String message, String user) { logger.append(message); logger.append(user); } } The programmer must guarantee that a single MyLogger object works properly for a multi-threaded system. How must this code be changed to be thread-safe?
- synchronize the log method
- replace StringBuilder with StringBufferNo change is necessary
- the current MyLogger code is already thread-safe.replace StringBuilder with just a String object and use the string concatenation (+=) within the log method
7841. Which is valid declarations within an interface definition?
- All of the above
- void methoda();
- public final double methoda();
- static void methoda(double d1);
7842. Given: static class A { void process() throws Exception { throw new Exception(); } } static class B extends A { void process() { System.out.println(“B”); } } public static void main(String[] args) { new B().process(); } What is the result?
- Compilation fails because of an error in line – void process() throws Exception { throw new Exception(); }.
- Compilation fails because of an error in line – void process() { System.out.println(“B”); }.
- The code runs with no output.
- B
7843. Which two are valid constructors for Thread?
- 1 and 2
- 2 and 5
- 2 and 4
- 1 and 3
আমাদের কাছে থাকা লক্ষ লক্ষ মডেল টেস্ট থেকে প্রাকটিজের জন্য কিছু এখানে তুলে ধরা হল। প্রতিটি অধ্যায়ের উপরে ইশিখন.কম কুইজ চ্যালেঞ্জ এ আছে শত শত মডেল টেস্ট বার বার মডেল টেস্ট দিয়ে নিজেকে যাচাই কর এবং পুরো বাংলাদেশের সকল শিক্ষার্থীর সাথে আপনার মেধা তালিকা দেখুন। প্রশ্নে কোন প্রকার ভুল থাকলে সঠিক উত্তরসহ নিচে কমেন্ট করে জানাবেন, আমরা ঠিক করে দেবো।
আমাদের অন্যান্য সেবাঃ
ডোমেইন হোস্টিংঃ http://hostbelt.com