Accenture Technical Interview Questions: Freshers and Experienced
- Static variable: When a variable is declared with the static keyword, a single copy of the variable will be created and the same variable will be shared across all objects of the class (a class to which the static variable belongs).
- Static block: A static block helps with the initialization of the static data members. It is a group of statements within a Java class and gets executed exactly once when the class is first loaded into the JVM(Java Virtual Machine).
- Static method: If the method is declared with the static keyword, then it is considered a static method. The main( ) method is one of the examples of a static method. Static methods are having restrictions such as they can directly call other static methods only, and they can access static data directly.
- Static class: Only a nested class can be created as a static class. Nested static class doesn’t need a reference of Outer class(a class in which the nested class is defined). A static class does not have permission to access non-static members of the Outer class.
What are lambda expressions in Java?
.class
file will not be created by the compiler.(argument_list) -> {body}
Three components of Lamda expression are:
-
argument_list
: Zero or more number of arguments. -
->
(arrow-token): Used to link argument_list and body of lambda expression. -
body
: Contains statements and expressions for lambda expression.
In the above example program, Example Interface is the functional interface that has a single abstract method abstractPrint(). By using lambda expression within InterviewBit class, we are implementing the functional interface by providing implementation code for the abstract method within an interface.
1 What is the difference between dictionary and tuple in Python?
Dictionary | Tuple |
---|---|
A dictionary is an unordered data collection in which data will be stored in the form of key-value pairs. | A tuple is an ordered data collection. |
Elements are accessed using key values. | Elements are accessed using numeric index values. |
Dictionary can have any number of values. | A tuple can have only a pre-defined number of values. |
It is used as a model object. | It is useful for returning multiple values from a function. |