Java Programming 2
Questions Result & StatisticsQuiz-summary
0 of 20 questions completed
Questions:
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
Information
Questions
Instruction:
- Total number of questions : 20
- Time allotted : 25 minutes.
- Each question carry 1 mark, no negative marks.
- Click the “Finish quiz” button given in bottom of this page to submit your answer.
- Test will be submitted automatically if the time expired.
- Don’t refresh the page.
You have already completed the quiz before. Hence you can not start it again.
Quiz is loading...
You must sign in or sign up to start the quiz.
You have to finish following quiz, to start this quiz:
Results
Marks : 0 of 20 questions answered correctly | ||
Total number of questions | : | 20 |
Number of currect answered | : | 0 |
Your time | : |
|
Time has elapsed
You have reached 0 of 0 points, (0)
Categories
- Not categorized 0%
-
Thank you for submitting online test!
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- Answered
- Review
-
Question 1 of 20
1. Question
1 points.
What would be the output of the following program?
class Scope1
{
public static void main(String args[])
{
int i=10;
System.out.println(i);
if (i==10)
{
int i=20;
System.out.println(i);
}
System.out.println(i);
}
}
CorrectAnswer : D
Explanation : In Java you can not define the same variable twice.
IncorrectAnswer : D
Explanation : In Java you can not define the same variable twice.
-
Question 2 of 20
2. Question
1 points.
What is the output of the following program?
class Operators1
{
public static void main(String[] args)
{
int i=0;
System.out.println(i++);
System.out.println(i);
System.out.println(++i);
}
}
CorrectAnswer : B
No answer description.
IncorrectAnswer : B
No answer description.
-
Question 3 of 20
3. Question
1 points.
What is the output of the following program?
class Operators2
{
public static void main(String[] args)
{
int i=0;
System.out.println(i–);
System.out.println(i);
System.out.println(–i);
}
}
CorrectAnswer : B
No answer description.
IncorrectAnswer : B
No answer description.
-
Question 4 of 20
4. Question
1 points.
What is the output of the following program?
class Operators1
{
public static void main(String[] args)
{
double d=10;
d=d<<2;
System.out.println(d);
}
}
CorrectAnswer : D
No answer description.
IncorrectAnswer : D
No answer description.
-
Question 5 of 20
5. Question
1 points.
What is the output of the following program?
class Operators1
{
public static void main(String[] args)
{
byte a=10;
System.out.println(~a);
}
}
CorrectAnswer : B
No answer description.
IncorrectAnswer : B
No answer description.
-
Question 6 of 20
6. Question
1 points.
What is the output of the following program?
class Operators1
{
public static void main(String[] args)
{
int a=10, b=0;
if( a < 10 || a/b == 10)
System.out.println(“Inside the If Condition!”);s
System.out.println(“Outside the If Condition!”);
}
}
CorrectAnswer : C
Explanation : The first expression a<10 is False. So the second expression is also evaluated. Causing a division by zero exception: Exception in thread “main” java.lang.ArithmeticException.
IncorrectAnswer : C
Explanation : The first expression a<10 is False. So the second expression is also evaluated. Causing a division by zero exception: Exception in thread “main” java.lang.ArithmeticException.
-
Question 7 of 20
7. Question
1 pointsCorrectAnswer : C
Explanation : JRE= JVM + Java Package Classes (util,lang …) +Runtime Libraries.
IncorrectAnswer : C
Explanation : JRE= JVM + Java Package Classes (util,lang …) +Runtime Libraries.
-
Question 8 of 20
8. Question
1 pointsCorrectAnswer : B
Explanation : The start() method causes this thread to begin execution; the Java Virtual Machine calls the run method of this thread.
IncorrectAnswer : B
Explanation : The start() method causes this thread to begin execution; the Java Virtual Machine calls the run method of this thread.
-
Question 9 of 20
9. Question
1 points.
Which two are valid constructors for Thread?
Thread(Runnable r, String name)
Thread()
Thread(int priority)
Thread(Runnable r, ThreadGroup g)
Thread(Runnable r, int priority)
CorrectAnswer : C
Explanation : (1) and (2) are both valid constructors for Thread.
IncorrectAnswer : C
Explanation : (1) and (2) are both valid constructors for Thread.
-
Question 10 of 20
10. Question
1 points.
Which three are methods of the Object class?
notify();
notifyAll();
isInterrupted();
synchronized();
interrupt();
wait(long msecs);
sleep(long msecs);
yield();
CorrectAnswer : C
Explanation : (1), (2), and (6) are correct. They are all related to the list of threads waiting on the specified object.
IncorrectAnswer : C
Explanation : (1), (2), and (6) are correct. They are all related to the list of threads waiting on the specified object.
-
Question 11 of 20
11. Question
1 points.
Which two of the following methods are defined in class Thread?
start()
wait()
notify()
run()
terminate()
CorrectAnswer : A
Explanation : (1) and (4). Only start() and run() are defined by the Thread class.
IncorrectAnswer : A
Explanation : (1) and (4). Only start() and run() are defined by the Thread class.
-
Question 12 of 20
12. Question
1 pointsCorrectAnswer : A
Explanation : wait() causes the current thread to wait until another thread invokes the notify() method or the notifyAll() method for this object.
IncorrectAnswer : A
Explanation : wait() causes the current thread to wait until another thread invokes the notify() method or the notifyAll() method for this object.
-
Question 13 of 20
13. Question
1 pointsCorrectAnswer : A
Explanation : The run() method to a thread is like the main() method to an application. Starting the thread causes the object’s run method to be called in that separately executing thread.
IncorrectAnswer : A
Explanation : The run() method to a thread is like the main() method to an application. Starting the thread causes the object’s run method to be called in that separately executing thread.
-
Question 14 of 20
14. Question
1 pointsCorrectAnswer : B
Explanation : The Runnable interface only contains 1 method, the void run() method therefore it must be implemented.
IncorrectAnswer : B
Explanation : The Runnable interface only contains 1 method, the void run() method therefore it must be implemented.
-
Question 15 of 20
15. Question
1 pointsCorrectAnswer : A
Explanation : notify() – wakes up a single thread that is waiting on this object’s monitor.
IncorrectAnswer : A
Explanation : notify() – wakes up a single thread that is waiting on this object’s monitor.
-
Question 16 of 20
16. Question
1 pointsCorrectAnswer : A
Explanation : The Object class defines these thread-specific methods.
IncorrectAnswer : A
Explanation : The Object class defines these thread-specific methods.
-
Question 17 of 20
17. Question
1 pointsCorrectAnswer : C
Explanation : Thread class is used to make threads in java, Thread encapsulates a thread of execution. To create a new thread the program will either extend Thread or implement the Runnable interface.
IncorrectAnswer : C
Explanation : Thread class is used to make threads in java, Thread encapsulates a thread of execution. To create a new thread the program will either extend Thread or implement the Runnable interface.
-
Question 18 of 20
18. Question
1 pointsCorrectAnswer : A
No answer description.
IncorrectAnswer : A
No answer description.
-
Question 19 of 20
19. Question
1 points.
Which of these method of Thread class is used to find out the priority given to a thread?
CorrectAnswer : C
No answer description.
IncorrectAnswer : C
No answer description.
-
Question 20 of 20
20. Question
1 pointsCorrectAnswer : A
No answer description.
IncorrectAnswer : A
No answer description.