• +91 9971497814
  • info@interviewmaterial.com

Computer Interview Questions Answers

Java Interview Questions Answers

Question - 171 : - What is more advisable to create a thread, by implementing a Runnable interface or by extending Thread class?

Answer - 171 : - Strategically speaking, threads created by implementing Runnable interface are more advisable. If you create a thread by extending a thread class, you cannot extend any other class. If you create a thread by implementing Runnable interface, you save a space for your class to extend another class now or in future.

Question - 172 : - What is shallow copy or shallow clone in array cloning?

Answer - 172 : - Cloning an array invloves creating a new array of the same size and type and copying all the old elements into the new array. But such copy is called shallow copy or shallow clone because any changes to the object would be reflected in both arrays.

Question - 173 : - How could Java classes direct program messages to the system console, but error messages, say to a file?

Answer - 173 : - The class System has a variable out that represents the standard output, and the variable err that represents the standard error device. By default, they both point at the system console. This how the standard output could be re-directed: Stream st = new Stream(new FileOutputStream("output.txt")); System.setErr(st); System.setOut(st);

Question - 174 : - Explain the usage of the keyword transient?

Answer - 174 : - This keyword indicates that the value of this member variable does not have to be serialized with the object. When the class will be de-serialized, this variable will be initialized with a default value of its data type (i.e. zero for integers).

Question - 175 : - What is scalability and performance?

Answer - 175 : - Performance is a measure of "how fast can you perform this task." and scalability describes how an application behaves as its workload and available computing resources increase.

Question - 176 : - Is there any other way that you can achieve inheritance in Java?

Answer - 176 : - There are a couple of ways. As you know, the straight way is to "extends" and/or "implements". The other way is to get an instance of the class to achieve the inheritance. That means to make the supposed-super-class be a field member. When you use an instance of the class, actually you get every function available from this class, but you may lose the dynamic features of OOP

Question - 177 : - What are three ways in which a thread can enter the waiting state?

Answer - 177 : - A thread can enter the waiting state by invoking its sleep() method, by blocking on IO, by unsuccessfully attempting to acquire an object's lock, or by invoking an object's wait() method. It can also enter the waiting state by invoking its (deprecated) suspend() method.

Question - 178 : - Is Java a super set of JavaScript?

Answer - 178 : - No. They are completely different. Some syntax may be similar.

Question - 179 : - What advantage do Java's layout managers provide over traditional windowing systems?

Answer - 179 : - Java uses layout managers to lay out components in a consistent manner across all windowing platforms. Since Java's layout managers aren't tied to absolute sizing and positioning, they are able to accommodate platform-specific differences among windowing systems.

Question - 180 : - What are order of precedence and associativity, and how are they used?

Answer - 180 : - Order of precedence determines the order in which operators are evaluated in expressions. Associatity determines whether an expression is evaluated left-to-right or right-to-left

Computer Contributors

krishan
Rajeev Katiyar
Yes Baroda

Share your email for latest updates

Name:
Email:

Our partners