AmbitionBox
Discover Best Places to work in India
Discover best places to work
Compare & find best workplace
Bring your workplace to life
Highlight your company's perks
Read reviews for 6L+ companies
Rate your former or current company
Discover salaries for 8L+ companies
Calculate your take home salary
Check your market value
Help other jobseekers
Read interviews for 90K+ companies
Interviews questions for 1K+ colleges
Contribute your interview questions
Java Programming
Consider the following piece of code:
float lu luckyNumber = 1.25;
System.out.println ( "The value of luckyNumber: " + luckyNumber );
What is the result?
A. The value of lucky number::
B. The value of lucky number: 1.25
C. The code would not compile
D. The code will compile but will give a runtime error.
Look this code:
1. class CodeWalkOne {
2. public static void main(String [] args) {
3. int [] counts = {1,2,3,4,5};
4. counts[1] = (counts[2] == 2) ? counts[3] : 99;
5. System.out.println(counts[1]);
6. }
7. }
A. Compilation fails on line 4.
B. 3
C. 4
D. 99
Consider the following code fragment:
1. public class Question{
2. public static void main(String[] args) {
3. byte x = 21;
4. byte y = 13;
5. int z = x^y;
6. System.out.println(z);
8. }
What is the result of this code fragment?
A. 24
B. 29
C. 21
D. A compiler error occurs at line 5.
Which of the following expressions is legal?
A. int x=9;
B. int y=!x;
C. double z=9.00>>2;
D. int i=^7;
Which of the following statements would not produce the compile error?
A. char my_char='c';
B. char your_char='int';
C. char what='hello';
D. char what_char="L";
Which method is used to perform interthread communications?
A. yield ( )
B. sleep (..)
C. notify ( )
D. wait ( )
Which of the following methods is not defined in the Thread class?
C. run ( )
What would happen when a thread executes the following statement in its run() method?
sleep(500);
A. It is going to stop execution and restart execution exactly after 500 milliseconds.
B. It is going to stop execution and restart execution not earlier than 500 milliseconds.
C. It will result in compiler error because sleep ( ) method cannot be called inside run ( ) method.
D. It will result in compiler error because the sleep ( ) method does not take any argument.
1. public class ThreadTest {
3. Counter ct = new Counter();
4. ct.start();
5. System.out.println("The thread has been started");
8. class Counter extends Thread {
9. protected void run() {
10. System.out.println("Hello");
11. }
12. }
What would be the output of this code fragment?
A. The thread has been started.
Hello
B. Hello
The thread has been started.
C. Either A or B
D. Compiler error on line 9
Join India’s largest community to research company culture
Are you a student or working professional?
Student/Never worked
I am a student/I have never worked
Working Professional
I am working/I have worked before
What are your preferred job locations?
Popular Cities
Other Cities
Follow your preferred designations/job profiles
Suggestions based on your job profile
vs
Similar Companies