Top 38 Java.lang Interview Questions
Q1. What Is The Output Of This Program?
1. Class Output
2. Public Static Void Main(string Args[])
three. Byte A[] = 65, 66, 67, 68, sixty nine, 70 ;
four.
System.Arraycopy() is a technique of sophistication System that's used to copy a string into any other string.
Output:
$ javac Output.Java
$ java Output
ABCDEF ABCDEF
Q2. What Is The Output Of This Program?
1. Class Output
2. Public Static Void Main(string Args[])
three. Byte A[] = 65, 66, 67, sixty eight, sixty nine, 70 ;
four.
Since final parameter of System.Arraycopy(a,1,b,3,0) is zero nothing is copied from array a to array b, therefore b remains as it is.
Q3. Which Of Interface Contains All The Methods Used For Handling Thread Related Operations In Java?
Runnable interface defines all the techniques for dealing with thread operations in Java.
Q4. What Is The Output Of This Program?
1. Class A
2. Int X;
3. Int Y;
4. Void Display()
5. System.Out.Print(x + " " +
clone() method of object class is used to generate replica replica of the object on which it's far called. Copy of obj1 is generated and saved in obj2.
Output:
$ javac Output.Java
$ java Output
1 2 1 2
Q5. Which Classes Is Not Included In Java.Lang?
Array magnificence is a member of java.Util.
Q6. Which Class Is Used To Make A Thread?
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 put into effect the Runnable interface.
Q7. What Is The Output Of This Program?
1. Class Newthread Implements Runnable
2. Thread T;
three. Newthread()
4. T = New Thread(this,"new Thread");
Thread t has been made with default priority fee 5 however in run technique the priority has been explicitly modified to MAX_PRIORITY of sophistication thread, this is 10 by means of code ‘t.SetPriority(Thread.MAX_PRIORITY);’ using the setPriority characteristic of thread t.
Output:
$ javac multithreaded_programing.Java
$ java multithreaded_programing
Thread[New Thread,10,main]
Q8. Which Method Return A Smallest Whole Number Greater Than Or Equal To Variable X?
Double ciel(double X) returns the smallest whole wide variety more than or equal to variable X.
Q9. What Is The Output Of This Program?
1. Class Output
2. Public Static Void Main(string Args[])
three. Double X = 2.Zero;
4. Double Y =
Math.Pow(x, y) methods returns price of y to the power x, i:e x ^ y, 2.0 ^ 3.0 = 8.0.
Output:
$ javac Output.Java
$ java Output
eight.0
Q10. What Is The Output Of This Program?
Character.IsDigit(a[0]) checks for a[0], whether or not it's far a digit or no longer, for the reason that a[0] i:e ‘a’ is a individual fake is returned. A[3] is a whitespace subsequently Character.IsWhitespace(a[3]) returns a true. A[2] is an higher case letter i:e ‘A’ hence Character.IsUpperCase(a[2]) returns actual.
Output:
$ javac Output.Java
$ java Output
fake true real
Q11. What Is The Output Of This Program?
1. Class Output
2. Public Static Void Main(string Args[])
3. Integer I = New Integer(257);
4.
Output:
$ javac Output.Java
$ java Output
257.Zero
Q12. What Is The Output Of This Program?
1. Class Output
2. Public Static Void Main(string Args[])
3. Byte A[] = sixty five, 66, sixty seven, sixty eight, sixty nine, 70 ;
four.
Output:
$ javac Output.Java
$ java Output
ABCDEF GCDEFL
Q13. What Is The Output Of This Program?
1. Class Output
2. Public Static Void Main(string Args[])
3. Int X = three.14;
four. Int Y = (i
Output:
$ javac Output.Java
$ java Output
3
Q14. Will This Program Generate Same Output Is Executed Again?
1. Class Output
2. Public Static Void Main(string Args[])
3. Int Y = Double Z = Math.Rand
There isn't any relation between random numbers generated previously in Java.
Q15. What Is The Output Of This Program?
1. Class Isnan_output
2. Public Static Void Main(string Args[])
three. Double D = New Double(1 / 0.);
4.
IsisNaN() approach returns true is the value being examined is a range of. 1/@is infinitely massive in importance, which cant now not be described as a number of as a result fake is saved in x.
Output:
$ javac isNaN_output.Java
$ java isNaN_output
fake
Q16. What Is The Output Of This Program?
1. Class Output
2. Public Static Void Main(string Args[])
3. Double X = three.14;
four. Int Y = (i
3.14 in diploma 179.908@We normally take it to be 18@Buts here we've got kind casted it to integer statistics type subsequently 179.
Output:
$ javac Output.Java
$ java Output
179
Q17. Which Methods Is Used To Check For Infinitely Large And Small Values?
Isinfinite() approach returns authentic is the cost being examined is infinitely large or small in significance.
Q18. What Is The Output Of This Program?
1. Class Binary
2. Public Static Void Main(string Args[])
3. Int Num = 17;
4. System.Out.P
output:
$ javac binary.Java
$ java binary
10001
Q19. What Is The Output Of This Program?
1. Class Output
2. Public Static Void Main(string Args[])
3. Integer I = New Integer(257);
4.
I.ByteValue() method returns the fee of wrapper i as a byte price. I is 257, range of byte is 256 consequently i value exceeds byte range with the aid of 1 for this reason 1 is again and stored in x.
Output:
$ javac Output.Java
$ java Output
1
Q20. What Is The Output Of This Program?
1. Class Newthread Implements Runnable
2. Thread T;
three. Newthread()
4. T = New Thread(this,"my Thread");<
Thread t has been made by way of the use of Runnable interface, as a result it's far necessary to apply inherited summary method run() technique to specify instructions to be carried out on the thread, when you consider that no run() technique is used it offers a compilation mistakes.
Output:
$ javac multithreaded_programing.Java
The kind newthread ought to enforce the inherited abstract method Runnable.Run()
Q21. What Is The Output Of This Program?
1. Class A
2. Int X;
three. Int Y;
4. Void Display()
five. System.Out.Print(x + " " + Y);<
clone() method of item elegance is used to generate reproduction copy of the item on which it's far referred to as. Copy of obj1 is generated and stored in obj2.
Output:
$ javac Output.Java
$ java Output
1 2 1 2
Q22. What Is The Output Of This Program?
1. Class Output
2. Public Static Void Main(string Args[])
three. Double X = 3.14;
4. Int Y =
ciel(double X) returns the smallest whole range greater than or identical to variable x.
Output:
$ javac Output.Java
$ java Output
four
Q23. What Is The Output Of This Program?
1. Class Newthread Implements Runnable
2. Thread T1,t2;
3. Newthread()
four. T1 = New Thread(this,"thread_1
Threads t1 & t2 are created by using class newthread that is imposing runnable interface, consequently each the threads are furnished their own run() technique specifying the actions to be taken. When constructor of newthread elegance is known as first the run() technique of t1 executes than the run method of t2 printing 2 instances “false” as both the threads are not equal one is having one-of-a-kind priority than different, therefore falsefalse is outlined.
Output:
$ javac multithreaded_programing.Java
$ java multithreaded_programing
falsefalse
Q24. Which Class Contains Only Floating Point Functions?
Math magnificence consists of all of the floating factor features which are used for geometry, trigonometry, as well as several wellknown reason methods. Example : sin(), cos(), exp(), sqrt() and many others.
Q25. What Is The Output Of This Program?
1. Class Isinfinite_output
2. Public Static Void Main(string Args[])
three. Double D = New Double(1 / 0.);
isInfinite() technique returns authentic is the fee being tested is infinitely massive or small in importance. 1/@is infinitely huge in value therefore genuine is saved in x.
Output:
$ javac isinfinite_output.Java
$ java isinfinite_output
actual
Q26. Which Class Is Superclass Of All Other Classes?
The object magnificence class is superclass of all other training.
Q27. Which Method Is A Rounding Function Of Math Class?
Max(), min() and abs() are all rounding functions.
Q28. What Is A Super Class Of Wrappers Long, Character & Integer?
Number is an abstract elegance containing subclasses Double, Float, Byte, Short, Integer and Long.
Q29. Which Class Contains All The Methods Present In Math Class?
SystemMath elegance defines whole set of mathematical methods that are parallel those in Math class. The difference is that the StrictMath version is assured to generate precisely same effects across all Java implementations.
Q30. Which Method Returns The Remainder Of Dividend / Devisor?
IEEEremainder() returns the remainder of dividend / devisor.
Q31. What Is A Super Class Of Wrappers Double & Integer?
Number is an abstract class containing subclasses Double, Float, Byte, Short, Integer and Long.
Q32. Which Method Return A Largest Whole Number Less Than Or Equal To Variable X?
Double ground(double X) returns a largest complete wide variety much less than or equal to variable X.
Q33. Toradian() And Todegree() Methods Were Added By Which Version Of Java?
ToRadian() and toDegree() techniques had been delivered via Java 2.0 before that there has been no technique that may at once convert diploma into radi and vice versa.
Q34. What Is The Output Of This Program?
1. Class Output
2. Public Static Void Main(string Args[])
three. Double X = 102;
4. Double Y = five;
IEEEremainder() returns the remainder of dividend / devisor. Here dividend is 102 and devisor is five therefore the rest is @It is much like modulus – ‘%’ operator of C/C++ language.
Output:
$ javac Output.Java
$ java Output
2
Q35. What Is The Output Of This Program?
1. Class Output
2. Public Static Void Main(string Args[])
3. Long Start, End;
4. Start = S
end time is the time taken by loop to execute it could be any non zero fee relying at the System.
Output:
$ javac Output.Java
$ java Output
78
Q36. What Is The Output Of This Program?
1. Class Output
2. Public Static Void Main(string Args[])
3. Long I = New Long(256);
four. Sys
Output:
$ javac Output.Java
$ java Output
256
Q37. Which Methods Is Used To Obtain Value Of Invoking Object As A Long?
Lengthy longValue() is used to attain price of invoking object as a long.
Q38. What Is The Output Of This Program?
1. Class Output
2. Public Static Void Main(string Args[])
three. Double X = 3.14;
4. Int Y =
double floor(double X) returns a largest complete quantity much less than or equal to variable X. Here the smallest whole range much less than three.14 is three.
Output:
$ javac Output.Java
$ java Output
three

