Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
37 views

Java Full Stack Interview Questions

credo systemz provide trending software course with professional staff

Uploaded by

csamalaridsonj
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views

Java Full Stack Interview Questions

credo systemz provide trending software course with professional staff

Uploaded by

csamalaridsonj
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Java Full Stack Interview Questions & Answers

1. What are wrapper classes in Java?


A class containing primitive data types. When we are creating an object to a wrapper class, a
field is available to store primitive data types.
2. What is the difference between an Array list and a vector in Java?
Vector and ArrayList uses arrays as data structures internally. They are dynamically resizable.
But, ArrayList increases by half of its size when its size is increased. Therefore as per Java
API the only main difference is, Vector’s methods are synchronized and ArrayList’s methods
are not synchronized.
3. How does cookies work in Servlets?
In cookies technique, we add cookies with response from the servlet. So the cookie is stored
in the cache of the browser. After that if a request is sent by the user, a cookie is added with
the request by default. Thus, we recognize the user as the old user.
4. Can we declare a class as Abstract without having any abstract method?
Yes, we can declare an abstract class without any abstract method. The purpose of declaring a
class as abstract is not to instantiate the class. Declaring an abstract class means that it cannot
be instantiated on its own and can only be subclassed.
5. Why is the Runnable Interface used in Java?
The Runnable interface should be implemented by any class whose instances are intended to
be executed by a thread. The class must define a method of no arguments called run. It is
designed to provide a common protocol for objects that wish to execute code while they are
active.
6. How to design a Good Key for HashMap?
Designing a good key results in efficient and predictable hashing behavior. The Key points to
be considered are:
➢ Keys should have constant hash code
➢ Good distribution of hash code
➢ equals() has to be consistent with hashCode()
➢ Implement the Comparable interface to sort and order keys.
7. What are memory areas allocated in JVM?
The Java virtual machine memory is a runtime area used for the execution of various
programs. The memory area of a JVM is broadly divided into different parts, such as:
➢ Method area,
➢ Heap area,
➢ Stack,
➢ Program counter (PC) registers area,
➢ Native method area.
8. Can you explain the internal workings of HashSet in java?
HashSet uses HashMap internally to store its objects. Whenever you create a HashSet object,
one HashMap object associated with it is also created. This HashMap object is used to store
the elements you enter in the HashSet. The elements you add into HashSet are stored as keys
of this HashMap object.
9. Difference between controlled and uncontrolled components?
In a controlled component, form data is handled by a React component which allows
validation control. In uncontrolled components, form data is handled by the DOM itself and
uses a ref to get form values from DOM.
10. “In React, everything is a component.” Explain?
Components are the building blocks of a React application’s UI which splits up the entire UI
into small independent.
11. What is Shallow Rendering in React testing?
Shallow rendering is a valuable technique for unit testing. It provides a controlled
environment to render a component without rendering its child components. It is useful to
ensure that the component works correctly, regardless of its children.
12. What is ReactDOMServer?
The ReactDOMServer object enables rendering components to static markup which is mainly
used for server-side rendering (SSR). The following methods can be used in both the server
and browser environments:
➢ renderToString()
➢ renderToStaticMarkup()
13. What are the Pointer Events supported in React?
Pointer Events provide a unified way of handling all input events. Many devices are used
nowadays that don’t correlate with a mouse, like phones with touch surfaces or pens. So we
need to remember that these events will only work in browsers that support the Pointer
Events specification.
14. How to format date using React Intl?
The injectIntl() higher-order component will give access to the formatDate() method via the
props in the component. It is used internally by instances of FormattedDate and it returns the
string representation of the formatted date.
15. What is the difference between $scope and scope in Angular?
In Angular js $scope is used whenever we have to use dependency injection (D.I) whereas the
scope is used for directive linking.
16. How did you get the value from the input box using JQuery?
To get the textbox value, use the jQuery val() function. For example, $(‘input:textbox’). val()
– Get textbox value.
17. Explain about let and const in ES6
In ES6 “const” will have block scoping just like the “let” keyword. A constant is a block
scope that cannot be shared its name with a function or a variable in the same scope. The
value of a constant cannot change through re-assignment. The const declaration creates a
read-only reference to a value.
18. What is TypeScript?
TypeScript is a free, open source programming language which is developed by Microsoft.
TypeScript is a syntactical superset of JavaScript. It is easy to maintain and comfortable to
interpret.
19. What is @NgModule?
An NgModule is a class marked by the @NgModule decorator. @NgModule is a decorator
for building web applications. The key features of @NgModule are:
➢ Imports
➢ Declarations
➢ Providers
➢ Exports
➢ Bootstrap
20. What is the Traceur compiler?
Traceur compiler takes classes, generators, and other features from ECMAScript edition 6
(ES6) and compiles it into JavaScript ES5 that runs on the browser. This means developers
can use the code from a future version that has more features and encourages design patterns.
21. What is NaN property in JavaScript?
NaN stands for Not a Number which represents a value that is not a valid number. It can be
used to check whether a number entered is a valid number or not a number. To assign a
variable to NaN value, we can use one of the two following ways.

var a = NaN
var a = Number.NaN.
22. Explain Higher Order Functions in JavaScript?
Functions can be assigned to variables in the same way that strings or arrays can. They can be
passed into other functions as parameters or returned from them as well. A “higher-order
function” is a function that accepts functions as parameters and/or returns a function.
23. What are the rules to be followed for variable naming conventions in JavaScript?
Rules:
➢ JavaScript variable names are case sensitive. For example, Test and test are two
different variables.
➢ Don’t use any of the JavaScript reserved keywords as variable names. For example,
break or boolean variable names are not valid.
➢ JavaScript variable names should not start with a numeral (0-9). They must begin with
a letter or the underscore character. For example, 123name is an invalid variable name
but _123name or name123 is a valid one.
24.What are all the loops available in JavaScript?
JavaScript provides several types of loops to handle repeated tasks, such as:
➢ For loop
➢ While loop
➢ do.. while loop
➢ For…in loop
➢ For…of loop
25. What are the different types of errors available in JavaScript?
The three types of errors are:
➢ Load time Errors: come up when we load a web page with inappropriate syntax
Errors. They are generated dynamically.
➢ Run time Errors: are generated due to misuse of command inside an HTML
language.
➢ Logical Errors: occur due to the formation or writing off bad logic inside the
program.
26. Write a Java program to find the first non-repeated character in a string.
Program:
import java.util.LinkedHashMap;
import java.util.Map;
public class FirstNonRepeatedCharacter {
public static char firstNonRepeatedChar(String str) {
Map<Character, Integer> charCountMap = new LinkedHashMap<>();
for (char c : str.toCharArray()) {
charCountMap.put(c, charCountMap.getOrDefault(c, 0) + 1);
}
for (Map.Entry<Character, Integer> entry : charCountMap.entrySet()) {
if (entry.getValue() == 1) {
return entry.getKey();
}
}
throw new RuntimeException(No non-repeated character found);
}

public static void main(String[] args) {


String str =swiss;
System.out.println(First non-repeated character: + firstNonRepeatedChar(str));
}
}

You might also like