Question 1
Answer
Question 1
What is a class in Java?
Answer
Answer: Java encapsulates the codes in various classes which define new data types. These new data types are used to create objects.
Question 2
Answer
Question 2
What is a JVM?
Answer
Answer: JVM is Java Virtual Machine which is a run time environment for the compiled java class files.
Question 3
Answer
Question 3
What is the right data type to represent a price in Java?
Answer
Answer: BigDecimal, if memory is not a concern and Performance, is not critical, otherwise double with predefined precision.
Question 4
Answer
Question 4
Does Java support multiple inheritances?
Answer
Answer: Java doesn’t support multiple inheritances.
Question 5
Answer
Question 5
What are the supported platforms by Java Programming Language?
Answer
Answer: Java runs on a variety of platforms, such as Windows, Mac OS, and the various versions of UNIX/Linux like HP-Unix, Sun Solaris, Red hat Linux, Ubuntu, Cent OS, etc.
Also Checkout: TCS NQT Sample Question Paper
Question 6
Answer
Question 6
List any five features of Java?
Answer
Answer: Some features include Object Oriented Platform, Independent, Robust, Interpreted, Multi-threaded.
Question 7
Answer
Question 7
What is JSP?
Answer
Answer: JSP is a technology that returns dynamic content to the Web client using HTML, XML and JAVAelements. JSP page looks like a HTML page but is a servlet. It contains Presentation logic andbusiness logic of a web application.
Question 8
Answer
Question 8
What restrictions are placed on the location of a package statement within a source code file?
Answer
Answer: A package statement must appear as the first line in a source code file (eliminating blank lines and comments).
Question 9
Answer
Question 9
What method is used to specify a container’s layout?
Answer
Answer: The setLayout() method is used to specify a container’s layout.
Question 10
Answer
Question 10
What are the access modifiers in Java?
Answer
Answer: There are 3 access modifiers. Public, protected and private, and the default one if no identifier is specified is called friendly, but programmer cannot specify the friendly identifier explicitly.
Question 11
Answer
Question 11
What is are packages?
Answer
Answer: A package is a collection of related classes and interfaces providing access protection and namespace management.
Question 12
Answer
Question 12
What is meant by Inheritance and What are its advantages?
Answer
Answer: Inheritance is the process of inheriting all the features from a class. The advantages of inheritance are reusability of code and accessibility of variables and methods of the super class by subclasses.
Question 13
Answer
Question 13
Can we rethrow the same exception from catch handler?
Answer
Answer: Yes, we can rethrow the same exception from our catch handler. If we want to rethrow checked exception from a catch block we need to declare that exception.
Question 14
Answer
Question 14
what value is a variable of the String type automatically initialized?
Answer
Answer: The default value of a String type is null.
Question 15
Answer
Question 15
When a thread blocks on I/O, what state does it enter?
Answer
Answer: When it blocks on I/O, A thread enters the waiting state.
Question 16
Answer
Question 16
Which containers use a Flow Layout as their default layout?
Answer
Answer: The Panel and Applet classes use the Flow Layout as their default layout.
Question 17
Answer
Question 17
Explain Java Coding Standards for Constants ?
Answer
Answer: Constants in java are created using static and final keywords.
Constants contain only uppercase letters.
If the constant name is a combination of two words it should be separated by an underscore. Constant names are usually nouns.
Ex: MAX_VALUE, MIN_VALUE, MAX_PRIORITY, MIN_PRIORITY
Question 18
Answer
Question 18
What is synchronization and why is it important?
Answer
Answer: The term synchronization is the ability to control the access of multiple threads to shared resources. And it is important because, without it, it is not possible for one thread to modify a shared object while another thread is in the process of using or updating that object’s value. This often leads to major errors.
Question 19
Answer
Question 19
Explain Java Coding Standards for variables?
Answer
Answer: Variable names should start with small letters.
Variable names should be nouns
Short meaningful names are recommended.
If there are multiple words every inner world should start with Uppercase character. Ex : string,value,empName,MEP salary
Question 20
Answer
Question 20
What is an abstract class?
Answer
Answer: An abstract class is a class designed with implementation gaps for subclasses to fill in and is deliberately incomplete.
Question 21
Answer
Question 21
What is the difference between JDK and JVM?
Answer
Answer: Full-Form: Java Development Kit Full Form: Java Virtual Machine For Development Purpose To execute the java programs It provides all the tools, executables and binaries required to compile, debug and execute a Java Program The execution part is handled by JVM to provide machine independence.
Question 22
Answer
Question 22
Why Java doesn’t support multiple inheritances?
Answer
Answer: Because of “Diamond Problem”, Java doesn’t support multiple inheritances in classes.
Question 23
Answer
Question 23
What modifiers may be used with an inner class that is a member of an outer class?
Answer
Answer: A (non-local) inner class may be declared as public, protected, private, static, final, or abstract.
Question 24
Answer
Question 24
Which java. util classes and interfaces support event handling?
Answer
Answer: The Event Object class and the Event Listener interface support event processing.
Question 25
Answer
Question 25
What is a transient variable?
Answer
Answer: A transient variable is a variable that may not be serialized.
Also Checkout