Rumman Ansari
Home
Blog
Courses
Paid Courses
Authentication
D365 F&O MCQ Questions - X++ Programming Language MCQ
Digital Productivity
GH-300: GitHub Copilot
ICSE Computer Applications Class 10 – Previous Year Question Papers & Solutions
Java Fundamentals: Building Strong Foundations
Mastering JavaScript: From Fundamentals to Advanced Concepts
MB-500: Microsoft Dynamics 365: Finance and Operations Apps Developer
X++ Programming Fundamentals - D365 F&O Technical
X++ Programming Language
Free Courses
AB-730: Microsoft Certified: AI Business Professional
AJAX
AngularJS
Arithmetic Aptitude
Artificial intelligence
Automata Theory
AZ-400: Designing and Implementing Microsoft DevOps Solutions
Azure DevOps for Beginners
Bangla to English
Biography
Biology
Bootstrap 4
C Programming Language
C Programming Language Video Bangla
C# Programming Language
C++ language
Competitive Exam
Computer Awareness
Computer Fundamentals
Computer Network
Computer Science and Engineering
Continuous Deployment
Continuous Integration
CSS
Current Affairs
Data Structure
Database Management System
Digital Logic
Education
Electrical Engineering
English
English Grammar
General Aptitude
Geography
History
HTML 5
Important Days and Dates
Interview Questions
ISC - COMPUTER SCIENCE - XI
Islam
Java Programming Language
JavaScript
Leadership behavior and Culture
Logical Fallacy
Machine Learning
Mastering HTML: From Fundamentals to Advanced Concepts
Mathematics
Mathematics for Programming
Mathematics in Bangla - Class 5
MB-310: Microsoft Certified: Dynamics 365 Finance Functional Consultant Associate
MB-330: Microsoft Certified: Dynamics 365 Supply Chain Management Functional Consultant Associate
MB-700: Microsoft Dynamics 365: Finance and Operations Apps Solution Architect
MB-920: Microsoft Dynamics 365 Fundamentals (ERP)
Microservices Architecture
Microsoft Azure
Microsoft Excel - Bangla
Mindwork games
Miscellaneous Topics
Misconceptions about Islam
MySQL
Neural Networks and Deep Learning
NPM - Package Manager
Pakistan Geography
Photoshop
PHP
Programming Language
Prompt Engineering
Puzzles
Python
R Programming Language
ReactJS
Science
Social Science
SQL
SQLite
Tamil Nadu State board (Class 10)
Technical MCQs
Technical Short Answers
TypeScript - JavaScript's Superset
UGC NET, SET
User Experience
Verbal and Reasoning
Vue JS
অতীত ও ঐতিহ্য: অষ্টম শ্রেণীর: পশ্চিমবঙ্গ মধ্যশিক্ষা পর্ষদ
অর্থনীতি
আরবী ভাষা কোর্স - Diploma in Arabic language
ইতিহাস
ইতিহাস ও পরিবেশ: দশম শ্রেণি: পশ্চিমবঙ্গ মধ্যশিক্ষা পর্ষদ
ইসলামিক বই
ইসলামে আকীকা
ইসলামে নারী
এসো আরবী শিখি
কুরআন
খাদ্য, পুষ্টি ও খাদ্যের উপাদান
জীবনবিজ্ঞান ও পরিবেশ (দশম)
তাহারাত কুইজ প্রতিযোগিতা
নবীদের কাহিনী - The story of the prophets
পরিবেশ ও বিজ্ঞান
প্যারেন্টিং - Parenting
প্রচলিত ভুল বিষয়ে প্রতিযোগিতা টেস্ট কুইজ
প্রশ্নোত্তরে ইসলামী জ্ঞান
বাংলা ইসলামিক কুইজ - Bangla Islamic Quiz
বাংলা সাহিত্য
ব্যক্তিগত উন্নয়ন (Personal Development)
ভূগোল
মডার্ন কম্পিউটার অ্যাপ্লিকেশন - একাদশ শ্রেণী
মডার্ন কম্পিউটার অ্যাপ্লিকেশন - দ্বাদশ শ্রেণী
লেখক এবং কবি
শয়তান পরিচিতি
সংক্ষিপ্ত জীবনী
সাধারণ জ্ঞান
সাহাবীদের জীবনী
সীরাত প্রতিযোগিতার প্রশ্ন ও উত্তরসমূহ
Guest
Profile
Logout
Green
Light
Dark
Java thread MCQ
Answer all questions carefully. After submission, you will see a detailed result and answer review.
Question 1
Which of the following constructor of class Thread is valid one?
A.
Thread(Runnable threadOb, int priority)
B.
Thread(int priority)
C.
Thread(Runnable threadOb, String threadName)
D.
Thread(String threadName, int priority)
Question 2
What is the output for the below code? <pre class="prettyprint"> class A implements Runnable{ public void run(){ System.out.println(Thread.currentThread().getName()); } } 1. public class Test{ 2. public static void main(String... args){ 3. A a = new A(); 4. Thread t = new Thread(a); 5. t.setName("good"); 6. t.start(); 7. } 8. } </pre>
A.
good
B.
null
C.
Compilation fails with an error at line 5
D.
Compilation succeed but Runtime Exception
Question 3
Predict the output: <pre class="prettyprint"> public class Test extends Thread{ private int i; public void run(){ i++; } public static void main(String[] args){ Test a = new Test(); a.run(); System.out.print(a.i); a.start(); System.out.print(a.i); } } </pre>
A.
Prints
B.
Prints
C.
Prints
D.
Compiler error
Question 4
What will be the output after compiling and executing the following code? <pre class="prettyprint"> public class Test implements Runnable{ public static void main(String[] args) throws InterruptedException{ Thread a = new Thread(new Test()); a.start(); System.out.print("Begin"); a.join(); System.out.print("End"); } public void run(){ System.out.print("Run"); } } </pre>
A.
Compilation fails.
B.
An exception is thrown at runtime.
C.
"BeginRunEnd" is printed.
D.
"BeginEndRun" is printed.
Question 5
What will be the output of the following program code? <pre class="prettyprint"> public class Test implements Runnable{ public static void main(String[] args){ Thread t = new Thread(this); t.start(); } public void run(){ System.out.println("test"); } } </pre>
A.
The program does not compile because this cannot be referenced in a static method.
B.
The program compiles fine, but it does not print anything because t does not invoke the run() method
C.
The program compiles and runs fine and displays test on the console.
D.
None of the above
Question 6
Given the code. What will be the result? <pre class="prettyprint"> public class Test implements Runnable{ public static void main(String[] args) throws InterruptedException{ Thread a = new Thread(new Test()); a.start(); System.out.print("Begin"); a.join(); System.out.print("End"); } public void run(){ System.out.print("Run"); } } </pre>
A.
Compilation fails.
B.
An exception is thrown at runtime.
C.
"BeginRunEnd" is printed.
D.
"BeginEndRun" is printed.
Question 7
What will be the output? <pre class="prettyprint"> class One extends Thread{ public void run(){ for(int i=0; i<2; i++){ System.out.print(i); } } } public class Test{ public static void main(String args[]){ Test t = new Test(); t.call(new One()); } public void call(One o){ o.start(); } } </pre>
A.
0 0
B.
Compilation Error
C.
0 1
D.
None of these
Question 8
What will happen when you attempt to compile and run the following code? <pre class="prettyprint"> 1. public class Test extends Thread{ 2. public static void main(String argv[]){ 3. Test t = new Test(); 4. t.run(); 5. t.start(); 6. } 7. public void run(){ 8. System.out.println("run-test"); 9. } 10. } </pre>
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
Question 9
Analyze the following code: <pre class="prettyprint"> public class Test implements Runnable{ public static void main(String[] args){ Test t = new Test(); } public Test(){ Thread t = new Thread(this); t.start(); } public void run(){ System.out.println("test"); } } </pre>
A.
The program has a compilation error because t is defined in both the main() method and the constructor Test().
B.
The program compiles fine, but it does not run because you cannot use the keyword this in the constructor.
C.
The program compiles and runs and displays nothing.
D.
The program compiles and runs and displays test.
Question 10
Which of the following are methods of the Thread class? <p>1) yield()<br />2) sleep(long msec)<br />3) go()<br />4) stop()</p>
A.
1 , 2 and 4
B.
1 and 3
C.
3 only
D.
None of the above
Submit Quiz