Sunday, November 16, 2014

25 LATEST TOP ADVANCED JAVA Interview Questions and Answers

Advanced Java Interview Questions and Answers :

What we can not do in jdbc but can do hibernate?
There are many thing we can do in hinernate automaticaly by hibernate tools or seting hibernate properties.some I giving below:

(1) We can migrate database just change database dielect.
(2)we can used caching
(3)if user do not know ant any SQL languge then they can use criteria query.
(4)There is one scnerio where SQL query are failed when want fetch obejct from db but do not know there ID.Hibernate provide this solution using HSQL.

Java is fully object oriented languages or not? Why?
No,java is not fully object oriented language because it does not support "multiple inheritence" and "pointers" which are used in C++.But,by using Interfaces we can implement multiple inheritence.Also,due to presence of Primitive datatypes,which are used in (AutoBoxing)...we can say it is not fully object oriented language.

If i learn Java, what kind of applications can i create that will help Banking, Retail, Hotel, Logistics industry?
When learned the java with the advanced concepts ,the application can be created for all the domain.Using the J2EE will be more friendly and efficiency in the code maintenance, since part of the code will be from the
framework

What is difference between object state and behavior?
If you change the state of an object, you ask it to perform a behavior. An object stores its states in a field e.g.variables, and demonstrates its behavior through methods.

Can we have more than one action servlet?
yes you can have and if you specify different url patter like
*.do for one action servlet
*.abc for other action servlet in your web.xml file

Why use a datasource when you can directly specify a connection details? (in a J2EE application)?
Because, it would be really difficult to specify the connection details in every method that access the database. Instead, if we create a data source, it can be used to connect to the database in every method we want.

If I define a method in JSP scriplet <%..%>, where will it go after translation into a servlet?
It will give compilation error. In order to define a method in JSP, it should be defined in the JSP declarations <%!..% >, and it can be called in the JSP expression.On translation, the method will be added outside all
methods in the servlet class.

How will the struts know which action class to call when you submit a form?
struts-config.xml in this file.
under the tag <type> absolute path of Action class under the tag <name> name of the action form class
Both of this will be called when the desired action mentioned under the <path> tag will be called and
struts-config.xml will call action class mentioned in the <type> tag and also populate the fields of form class
mentioned under <name> tag.

Will it be called overriding if I do not change the parameters or return type, instead throw a different exception in the method signature?
yes, you will be overriding to throw a different exception

Does Java pass arguments by value or reference?
Pass by value.
1. When passing primitives, it passes a copy of the variable to the method. Any change made in the method does not reflect in the calling method.
2. When dealing with objects, a copy of their reference/address is passed. Thus the change made to the
object is reflected in the calling method.

Different between Struts and Spring? or Why use Spring, if you are already using Struts?
Struts:
1.Struts is only for web Applications.We can not develop any type of Java,J2EE applications by using Struts Framework.
2.We can not Integrate other Frameworks with Any other Java Oriented Frameworks.

Spring:
1.Spring is for developing any kind of Java,J2EE applications.
2.It is Layered architecture.We can integrate any no of
Frameworks with Spring.
3.It has So many features like AOP,IOC.

Explain what is synchronization?
When multiple threads working,Synchronization is to lock a method for a particular object.

Write a program to show synchronization?
public someClass{
public synchronised methodA(){
//write your code
}
}

Explain what is orm?
Object Relational Mapping ,its a tool for transaction management that needs to be integrated with Spring,Struts etc.Eg : Hibernate,iBatis,JDO etc

Write a singleton program?
Having single instance through out the application.eg.: Loggers

What is IOC concept & explain it?
Injecting dependencies to object itself instead of depending on container.

Explain spring framework?
Spring is lightweight,Inversion controlled,Aspect oriented ,Container framework.

What are the oops concept?
Inhertitance, Encapsulation, Polymorphism, Data Abstraction

What are the diff types of exception?
Unchecked and Checked exceptions

What is AOP(assepct oriented programing)?
Separating your business logic with other functionalit
y such as services,Loggers etc,Making classess more cohesive.

What is jsp life cycle?
jspinit(),_jspService(),jspdestroy()

Explain servlet life cycle?
init(),service(),destroy()

What is prototype?
Having multiple instances or having clones

In spring bean class uses singleton or prototype?
By Default spring uses singleton or mention singleton="true" for singleton else false for prototype inside bean tag.

20 LATEST TOP CORE JAVA Interview Questions and Answers

CORE JAVA Interview Questions and Answers :

Explain about Core Java?
Java is increasingly used for middleware applications to communicate between Server and clients. Java has features such as multithreading, portability and networking capabilities. Changes in the java library made java as a favorite programming language for developers it added functionality to their scripts.

State some advantages of Java?
Platform independence is the key feature of Java during runtime. Syntax of java is similar to the popular object oriented languages such as C and C++. Java program can eliminate most of the bugs present in the program. Manual memory allocation and de allocation feature present in Java is automated.

State the main difference between C++ and Java?
The main difference between C++ and Java lies in multiple inheritances. Java Meta class model has a better solution than C++. Persistent objects can be implemented by features such as object serialization and reflection mechanism. GUI can be implemented easily.

Explain about the security aspect of Java?
Java has some bugs in its applets. Java team stated that they have zero tolerance over security features and subsequent editions of Java are improving Bug free environment. Some of the features are overriding the runtime stack, disallowing the corruption of memory outside its own process, reading or writing on local files where it is actually forbidden to do these processes, etc.

Explain about the interpreter in Java?
Machines should have Java interpreter for the Java byte code to get executed. Linking is a very easy process and this feature helps while developing applications. Java compiler which is available with software development kit is a bit slower in execution of scripts.

Explain about the performance aspects of Core Java?
Performance of interpreted byte codes is enough but it can be improved much more than that. Byte codes are translated into machine language within no time, this speed of execution can be achieved during application compiling time. JIT compilers are also present which compile the byte codes into native code.

Explain about the dynamic behavior of core java?
This language was designed to adapt the changing environment and behavior. New methods and instance variables can be added to the client side without any major changes happening at the client end. This function is very important for GUI builders, pluggable components, debuggers and object database.

Explain about Java SDK?
Java SDK is not so comfortable with people used to command line interpreter. IDEs include compilers, editors, debugging facilities, drag and drop techniques, etc. This compiler strives to generate hundreds of lines in code UI. This platform may become a universal platform.

What are the three best choices for development environment?
The three best choices for development environment include.
1) Java SDK and text editor can be a perfect choice.
2) Java SDK and a text editor which is built within the SDK.
3) Using IDE such as free Forte community edition.

Explain about Class in Java?
In Java every thing exists within a class. It defines the behavior of the class and its characteristics. Java applications and applets are built in the class. Rules present for class name are generous and some of the basic rules are names should start with a letter after that letter they can have any combination of letters and digits. It can contain names to any length.

Explain about Java data types?
Variables declared should have a declared type. Out of the eight data types four data types are integer, two are floating type integers, one is character type out of which one is Boolean and the other Unicode. Core Java is known to be a strong typed language.

Explain about Java assignment statement?
After declaring a variable, it should be initialized explicitly. Uninitialized variable can never be used. To a declared variable you must assign a variable name on the left, equal sign and a java expression should have a appropriate value to the right.

Give the difference between the println method and sqrt method?
Println method operates on the object system.out and has the value which should be printed namely y. sqrt method is a static method. It does not operate on any object. It has the number stored in x for which the square toot should be found out.

Explain about strings in Java?
Strings represent nothing but a string of characters. Java does not have any built in string type. It contains predefined class which can be called enough as a String. Instance of a string is called as a string. Much similar to many object oriented languages a + sign is used.

Explain the reason behind ending a program with a System.exit (0)?
The reason behind ending a program with System.exit (0) involves technicalities. When main method exits the new thread automatically does not end. The appearance of this thread is because of dialog box functionality. System.exit ends all the methods.

Explain about inheritance hierarchies?
An inheritance hierarchy has a collection of all classes which fall under the main class. Inheritance chain defines the path from where all the sub classes originated and their relation ship. Controller normally handles user input. Inheritance hierarchy is very important in software modeling.

Explain about the select method with an example?
Select part is useful in selecting text or part of the text. Arguments specified for the select command are the same as applicable to substring. First index is usually represents the start of the index. End of line makers are counted as one character. Example t.select (10,15)

Saturday, September 20, 2014

70 LATEST TOP JAVASCRIPT Interview Questions and Answers

Below are the list of Latest JAVASCRIPT interview questions and answers for freshers beginners and experienced pdf free download.
 

JAVASCRIPT Interview Questions and Answers


JAVASCRIPT Interview Questions
JAVASCRIPT Interview Questions
What is JavaScript?
A1: JavaScript is a general-purpose programming language designed to let programmers of all skill levels control the behavior of software objects. The language is used most widely today in Web browsers whose software objects tend to represent a variety of HTML elements in a document and the document itself. But the language can be--and is--used with other kinds of objects in other environments. For example, Adobe Acrobat Forms uses JavaScript as its underlying scripting language to glue together objects that are unique to the forms generated by Adobe Acrobat. Therefore, it is important to distinguish JavaScript, the language, from the objects it can communicate with in any particular environment. When used for Web documents, the scripts go directly inside the HTML documents and are downloaded to the browser with the rest of the HTML tags and content.

A2:JavaScript is a platform-independent,event-driven, interpreted client-side scripting and programming language developed by Netscape Communications Corp. and Sun Microsystems.

How is JavaScript different from Java?
JavaScript was developed by Brendan Eich of Netscape; Java was developed at Sun Microsystems. While the two languages share some common syntax, they were developed independently of each other and for different audiences. Java is a full-fledged programming language tailored for network computing; it includes hundreds of its own objects, including objects for creating user interfaces that appear in Java applets (in Web browsers) or standalone Java applications. In contrast, JavaScript relies on whatever environment it's operating in for the user interface, such as a Web document's form elements.
JavaScript was initially called LiveScript at Netscape while it was under development. A licensing deal between Netscape and Sun at the last minute let Netscape plug the "Java" name into the name of its scripting language. Programmers use entirely different tools for Java and JavaScript. It is also not uncommon for a programmer of one language to be ignorant of the other. The two languages don't rely on each other and are intended for different purposes. In some ways, the "Java" name on JavaScript has confused the world's understanding of the differences between the two. On the other hand, JavaScript is much easier to learn than Java and can offer a gentle introduction for newcomers who want to graduate to Java and the kinds of applications you can develop with it.

What’s relationship between JavaScript and ECMAScript?
ECMAScript is yet another name for JavaScript (other names include LiveScript). The current JavaScript that you see supported in browsers is ECMAScript revision 3.

How do you submit a form using Javascript?
Use document.forms[0].submit();
(0 refers to the index of the form – if you have more than one form in a page, then the first one has the index 0, second has index 1 and so on).

How do we get JavaScript onto a web page?
You can use several different methods of placing javascript in you pages.
You can directly add a script element inside the body of page.
1. For example, to add the "last updated line" to your pages, In your page text, add the following:
<p>blah, blah, blah, blah, blah.</p>
<script type="text/javascript" >
<!-- Hiding from old browsers
document.write("Last Updated:" +
document.lastModified);
document.close();
// -->
</script>
<p>yada, yada, yada.</p>

(Note: the first comment, "<--" hides the content of the script from browsers that don't understand javascript. The "// -->" finishes the comment. The "//" tells javascript that this is a comment so javascript doesn't try to interpret the "-->". If your audience has much older browsers, you should put this comments inside your javascript. If most of your audience has newer browsers, the comments can be omitted. For brevity, in most examples here the comments are not shown. )
The above code will look like this on Javascript enabled browsers,
2. Javascript can be placed inside the <head> element
Functions and global variables typically reside inside the <head> element.
<head>
<title>Default Test Page</title>
<script language="JavaScript" type="text/javascript">
var myVar = "";
function timer(){setTimeout('restart()',10);}
document.onload=timer();
</script>
</head>

Javascript can be referenced from a separate file
Javascript may also a placed in a separate file on the server and referenced from an HTML page. (Don't use the shorthand ending "<script ... />). These are typically placed in the <head> element.
<script type="text/javascript" SRC="myStuff.js"></script>

How to read and write a file using javascript?
I/O operations like reading or writing a file is not possible with client-side javascript. However , this can be done by coding a Java applet that reads files for the script.

How to detect the operating system on the client machine?
In order to detect the operating system on the client machine, the navigator.appVersion
string (property) should be used.

How can JavaScript make a Web site easier to use? That is, are there certain JavaScript techniques that make it easier for people to use a Web site?
JavaScript's greatest potential gift to a Web site is that scripts can make the page more immediately interactive, that is, interactive without having to submit every little thing to the server for a server program to re-render the page and send it back to the client. For example, consider a top-level navigation panel that has, say, six primary image map links into subsections of the Web site. With only a little bit of scripting, each map area can be instructed to pop up a more detailed list of links to the contents within a subsection whenever the user rolls the cursor atop a map area. With the help of that popup list of links, the user with a scriptable browser can bypass one intermediate menu page. The user without a scriptable browser (or who has disabled JavaScript) will have to drill down through a more traditional and time-consuming path to the desired content.

What are JavaScript types?
Number, String, Boolean, Function, Object, Null, Undefined.

How do you convert numbers between different bases in JavaScript?
Use the parseInt() function, that takes a string as the first parameter, and the base as a second parameter. So to convert hexadecimal 3F to decimal, use parseInt ("3F", 16);

What does "1"+2+3 evaluate to?
Since 1 is a string, everything is a string, so the result is 123.

How about 3+5+"8"?
Since 3 and 5 are integers, this is number arithmetic, since 8 is a string, it’s concatenation, so 88 is the result.

How do you submit a form using Javascript?
Use document.forms[0].submit();

How do you assign object properties?
obj["age"] = 22 or obj.age = 22.

What’s a way to append a value to an array?
arr[arr.length] = value;

What does isNaN function do?
Return true if the argument is not a number.

What’s relationship between JavaScript and ECMAScript?
ECMAScript is yet another name for JavaScript (other names include LiveScript). The current JavaScript that you see supported in browsers is ECMAScript revision 3.

How to read and write a file using javascript?
I/O operations like reading or writing a file is not possible with client-side javascript.

How do you convert numbers between different bases in JavaScript?
Use the parseInt() function, that takes a string as the first parameter, and the base as a second parameter. So to convert hexadecimal FF to decimal, use parseInt ("FF", 16);

What is negative infinity?
It’s a number in JavaScript, derived by dividing negative number by zero.

How to set a HTML document's background color?
document.bgcolor property can be set to any appropriate color.

What boolean operators does JavaScript support?
&&, and !

How to get the contents of an input box using Javascript?
Use the "value" property.
var myValue = window.document.getElementById("textboxID").value;

How to determine the state of a checkbox using Javascript?
var checkedP = window.document.getElementById("CheckBoxID").checked;

How to set the focus in an element using Javascript?
<script> function setFocus() { if(focusElement != null) { document.forms[0].elements["myelementname"].focus(); } } </script>

How to access an external javascript file that is stored externally and not embedded?
This can be achieved by using the following tag between head tags or between body tags.
<script src="raj.js"></script>How to access an external javascript file that is stored externally and not embedded? where abc.js is the external javscript file to be accessed.

What is the difference between an alert box and a confirmation box?
An alert box displays only one button which is the OK button whereas the Confirm box displays two buttons namely OK and cancel.

What is a prompt box?
A prompt box allows the user to enter input by providing a text box.

Can javascript code be broken in different lines?
Breaking is possible within a string statement by using a backslash \ at the end but not within any other javascript statement.
that is ,
document.write("Hello \ world");
is possible but not document.write \
("hello world");

What looping structures are there in JavaScript?
for, while, do-while loops, but no foreach.

How do you create a new object in JavaScript?
var obj = new Object(); or var obj = {};

What is this keyword?
It refers to the current object.


What is the difference between SessionState and ViewState?
ViewState is specific to a page in a session. Session state refers to user specific data that can be accessed across all pages in the web application.


What looping structures are there in JavaScript?
for, while, do-while loops, but no foreach.

To put a "close window" link on a page ?
<a href='javascript:window.close()' class='mainnav'> Close </a>

How to hide javascript code from old browsers that dont run it?
Use the below specified style of comments <script language=javascript> <!-- javascript code goes here // --> or Use the <NOSCRIPT>some html code </NOSCRIPT> tags and code the display html statements between these and this will appear on the page if the browser does not support javascript

How to comment javascript code?
Use // for line comments and
/*
*/ for block comments

Name the numeric constants representing max,min values
Number.MAX_VALUE
Number.MIN_VALUE

What does javascript null mean?
The null value is a unique value representing no value or no object.
It implies no object,or null string,no valid boolean value,no number and no array object.

How do you create a new object in JavaScript?
var obj = new Object(); or var obj = {};

How do you assign object properties?
obj["age"] = 23 or obj.age = 23.

What’s a way to append a value to an array?
arr[arr.length] = value;


To set all checkboxes to true using JavaScript?
//select all input tags
function SelectAll() {
var checkboxes = document.getElementsByTagName("input");
for(i=0;i<checkboxes.length;i++) {
if(checkboxes.item(i).attributes["type"].value == "checkbox") {
checkboxes.item(i).checked = true;
}
}
}

What does undefined value mean in javascript?
Undefined value means the variable used in the code doesn't exist or is not assigned any value or the property doesn't exist.

What is the difference between undefined value and null value?
(i)Undefined value cannot be explicitly stated that is there is no keyword called undefined whereas null value has keyword called null
(ii)typeof undefined variable or property returns undefined whereas typeof null value returns object

What is variable typing in javascript?
It is perfectly legal to assign a number to a variable and then assign a string to the same variable as follows
example
i = 10;
i = "string";
This is called variable typing

Does javascript have the concept level scope?
No. JavaScript does not have block level scope, all the variables declared inside a function possess the same level of scope unlike c,c++,java.

What are undefined and undeclared variables?
Undeclared variables are those that are not declared in the program (do not exist at all),trying to read their values gives runtime error.But if undeclared variables are assigned then implicit declaration is done .
Undefined variables are those that are not assigned any value but are declared in the program.Trying to read such variables gives special value called undefined value.

What is === operator ?
==== is strict equality operator ,it returns true only when the two operands are having the same value without any type conversion.


How to disable an HTML object ?
document.getElementById("myObject").disabled = true;

How to create a popup warning box?
alert('Warning: Please enter an integer between 0 and 1000.');

How to create a confirmation box?
confirm("Do you really want to launch the missile?");

How to create an input box?
prompt("What is your temperature?");

How to force a page to go to another page using JavaScript ?
<script language="JavaScript" type="text/javascript" ><!-- location.href="http://rajeshstutorials.blogspt.com"; //--></script>

What's Math Constants and Functions using JavaScript?
The Math object contains useful constants such as Math.PI, Math.E

Math.abs(value); //absolute value
Math.max(value1, value2); //find the largest
Math.random() //generate a decimal number between 0 and 1
Math.floor(Math.random()*101) //generate a decimal number between 0 and 100

What does the delete operator do?
The delete operator is used to delete all the variables and objects used in the program ,but it does not delete variables declared with var keyword.

How to get value from a textbox?
alert(document.getElementById('txtbox1').value);

How to get value from dropdown (select) control?
alert(document.getElementById('dropdown1').value);

Tuesday, September 16, 2014

80 LATEST TOP SAP ABAP Multiple Choice Questions and Answers pdf

Below are the List of Top 80 SAP ABAP Internal Tables Interview Questions and Answers for pdf, SAP Certification Questions and Answers for freshers and Experienced.

Sap Abap Interview Questions and Answers

SAP ABAP Questions and Answers

Sap Abap Interview Questions


1. This data type has a default length of one and a blank default value.
A: I
B: N
C: C
D: D
Ans:C

2. A DATA statement may appear only at the top of a program, before START-OFSELECTION.
A: True
B: False
Ans:B

3. If a field, NAME1, is declared as a global data object, what will be output by the
following code?
report zabaprg.
DATA: name1 like KNA1-NAME1 value 'ABAP programmer'.
name1 = 'Customer name'.
CLEAR name1.
perform write_name.
FORM write_name.
name1 = 'Material number'.
WRITE name1.
ENDFORM.
A: Customer name
B: ABAP programmer
C: Material number
D: None of the above
Ans:C

4. All of these allow you to step through the flow of a program line-by-line except:
A: Enter /h then execute
B: Execute in debug mode
C: Enter /i then execute
D: Set a breakpoint
Ans: C

5. Which of the following may NOT be modified using the ABAP Dictionary
transaction?
A: Type groups
B: Search help
C: Lock objects
D: Function groups
Ans:D

6. In a line of code, text-100, is an example of which type of text element?
A: Text symbol
B: Selection text
C: Text title
D: Text identifier
Ans:A

7. The editor function that formats and indents the lines of code automatically is called
____.
A: Auto align
B: Pretty printer
C: Generate version
D: Syntax check
Ans:B

8. A DO loop increments the system field ____.
A: SY-LOOPI
B: SY-TABIX
C: SY-LSIND
D: SY-INDEX
Ans: D

9. The event that is processed after all data has been read but before the list is displayed
is:
A: END-OF-PAGE.
B: START-OF-SELECTION.
C: END-OF-SELECTION.
D: AT LINE-SELECTION.
Ans:A ? C

10. The field declared below is of what data type?
DATA: new_fld(25).
A: P
B: N
C: I
D: C
Ans: D

11. In regard to the INITIALIZATION event, which of the following is NOT a true
statement?
A: Executed before the selection screen is displayed.
B: You should use SET PF-STATUS here.
C: You can assign different values to PARAMETERS and SELECT-OPTIONS here.
D: Executed one time when you start the report.
Ans: B

12. The event AT SELECTION-SCREEN OUTPUT. occurs before the selection screen
is displayed and is the best event for assigning default values to selection criteria.
A: True
B: False
Ans: B

13. The business (non-technical) definition of a table field is determined by the field's
____.
A: domain
B: field name
C: data type
D: data element
Ans: D

14. In regard to the three-tier client/server architecture, which of the following is a true
statement?
A: The presentation server processes the SAP program logic.
B: An application server is responsible for updating database tables.
C: Typically, there is a one-to-one ratio of database servers to presentation servers.
D: The application server layer is the level between a presentation server and a
database server.
Ans: D,B

15. What will be output by the code below?
DATA: alph type I value 3.
write: alph.
WHILE alph > 2.
write: alph.
alph = alph - 1.
ENDWHILE.
A: 3
B: 3 2
C: 3 3 2
D: 3 3
Ans: D

16. To allow the user to enter a single value on a selection screen, use the ABAP
keyword ____.
A: SELECT-OPTIONS.
B: PARAMETERS.
C: RANGES.
D: DATA.
Ans: B

17. What will be output by the following code?
DATA: BEGIN OF itab OCCURS 0, fval type i, END OF itab.
itab-fval = 1. APPEND itab.
itab-fval = 2. APPEND itab.
REFRESH itab.
WRITE: /1 itab-fval.
A: 1
B: 2
C: blank
D: 0
Ans: B

18. You can define your own key fields when declaring an internal table.
A: True
B: False
Ans: A

19. When modifying an internal table within LOOP AT itab. _ ENDLOOP. you must
include an index number.
A: True
B: False
Ans : B

20. If itab contains 20 rows, what will SY-TABIX equal when the program reaches the
WRITE statement below?
SY-TABIX = 10.
LOOP AT itab.
count_field = count_field + 1.
ENDLOOP.
WRITE: /1 count_field.
A: 0
B: 10
C: 20
D: 30
Ans: C

More SAP ABAP Interview Questions : Click Here

21. Adding a COMMIT WORK statement between SELECT_ENDSELECT is a good
method for improving performance.
A: True
B: False
Ans:B

22. To select one record for a matching primary key, use ____.
A: SELECT
B: SELECT INTO
C: SELECT SINGLE
D: SELECT ENTRY
Ans: C

23. In regard to MOVE-CORRESPONDING, which of the following is NOT a true
statement?
A: Moves the values of components with identical names.
B: Fields without a match are unchanged.
C: Corresponds to one or more MOVE statements.
D: Moves the values of components according to their location.
Ans: D

24. The ABAP keyword for adding authorizations to a program is ____.
A: AUTH-CHECK
B: AUTHORITY-CHECK
C: AUTHORIZATION-CHECK
D: AUTHORITY-OBJECT
Ans:B

25. To read an exact row number of an internal table, use this parameter of the READ
TABLE statement.
A: INDEX
B: TABIX
C: ROW
D: WHERE
Ans: B ? A

26. To remove lines from a database table, use ____.
A: UPDATE
B: MODIFY
C: ERASE
D: DELETE
Ans: D

27. Which table type would be most appropriate for accessing table rows using an
index.
A: Hashed table
B: Standard table
C: Sorted table
D: None of these may be accessed using an index.
Ans: C

28. The following code indicates:
SELECTION-SCREEN BEGIN OF BLOCK B1.
PARAMETERS: myparam(10) type C,
Myparam2(10) type N,
SELECTION-SCREEN END OF BLOCK.
A: Draw a box around myparam and myparam2 on the selection screen.
B: Allow myparam and myparam2 to be ready for input during an error dialog.
C: Do not display myparam and myparam2 on the selection screen.
D: Display myparam and myparam2 only if both fields have default values.
Ans: A

29. The following code reorders the rows so that:
DATA: itab LIKE kna1 OCCURS 0 WITH HEADER LINE.
itab-name1 = 'Smith'. itab-ort01 = 'Miami'. APPEND itab.
itab-name1 = 'Jones'. itab-ort01 = 'Chicago'. APPEND itab.
itab-name1 = 'Brown'. itab-ort01 = 'New York'. APPEND itab.
SORT itab BY name1 ort01.
A: Smith appears before Jones
B: Jones appears before Brown
C: Brown appears before Jones
D: Miami appears before New York
Ans: C

30. If a table contains many duplicate values for a field, minimize the number of
records returned by using this SELECT statement addition.
A: MIN
B: ORDER BY
C: DISTINCT
D: DELETE
Ans:C

31. When writing a SELECT statement, you should place as much load as possible on
the database server and minimize the load on the application server.
A: True
B: False
Ans: B

32. All of the following pertain to interactive reporting in ABAP except:
A: Call transactions and other programs from a list.
B: Secondary list shows detail data.
C: Good for processing lists in background.
D: AT USER-COMMAND
Ans:C

33. In regard to a function group, which of the following is NOT a true statement?
A: Combines similar function modules.
B: Shares global data with all its function modules.
C: Exists within the ABAP workbench as an include program.
D: Shares subroutines with all its function modules.
Ans: D

34. Errors to be handled by the calling program are defined in a function module's
____.
A: exceptions interface
B: source code
C: exporting interface
D: main program
Ans :A

35. In regard to the START-OF-SELECTION event, which of the following is a true
statement?
A: Executed before the selection screen is displayed.
B: This is the only event in which a SELECT statement may be coded.
C: Executed when the user double-clicks a list row.
D: Automatically started by the REPORT statement.
Ans:D

36. The order in which an event appears in the ABAP code determines when the event
is processed.
A: True
B: False
Ans: B

37. The SAP service that ensures data integrity by handling locking is called:
A: Update
B: Dialog
C: Enqueue/Dequeue
D: Spool
Ans: C

38. What standard data type is the following user-defined type?
TYPES: user_type.
A: N
B: C
C: I
D: Undefined
Ans: B

39. Which ABAP program attribute provides access protection?
A: Status
B: Application
C: Development class
D: Authorization group
Ans:D

40. Page headers for a secondary list should be coded in which event?
A: TOP-OF-PAGE.
B: START-OF-SELECTION.
C: TOP-OF-PAGE DURING LINE-SELECTION.
D: AT USER-COMMAND.
Ans: C

41. Given:
PERFORM subroutine USING var.
The var field is known as what type of parameter?
A: Formal
B: Actual
C: Static
D: Value
Ans:B

42. The following statement will result in a syntax error.
DATA: price(3) type p decimals 2 value '100.23'.
A: True
B: False
Ans: B

43. The following code indicates:
CALL SCREEN 300.
A: Start the PAI processing of screen 300.
B: Jump to screen 300 without coming back.
C: Temporarily branch to screen 300. *
D: Exit screen 300.
Ans:C

44. Which of the following would be stored in a table as master data?
A: Customer name and address
B: Sales order items
C: Accounting invoice header
D: Vendor credit memo
Ans: A

45. In relation to an internal table as a formal parameter, because of the STRUCTURE
syntax, it is possible to:
A: Use the DESCRIBE statement within a subroutine.
B: Loop through the internal table within a subroutine.
C: Access the internal table fields within a subroutine.
D: Add rows to the internal table within a subroutine.
Ans: C

46. This data type has a default length of one and a default value = '0'.
A: P
B: C
C: N
D: I
Ans: C

47. To prevent duplicate accesses to a master data field:
A: Create an index on the master data field.
B: Remove nested SELECT statements.
C: Use SELECT SINGLE.
D: Buffer the data in an internal table.
Ans: A ? C

48. In regard to the code below, which of the following is not a true statement?
TABLES: KNA1.
GET KNA1.
Write: /1 kna1-kunnr.
END-OF-SELECTION.
A: The GET event is processed while a logical database is running.
B: All the fields from table KNA1 may be used in the GET event.
C: You can code the GET event elsewhere in the same program.
D: None of the above.
Ans: D

49. The following code indicates:
SELECT fld1 FROM tab1 INTO TABLE itab
UP TO 100 ROWS
WHERE fld7 = pfld7.
A: Itab will contain 100 rows.
B: Only the first 100 records of tab1 are read.
C: If itab has less than 100 rows before the SELECT, SY-SUBRC will be set to 4.
D: None of the above.
Ans: D

50. To place a checkbox on a list, use
A: WRITE CHECKBOX.
B: FORMAT CHECKBOX ON.
C: WRITE fld AS CHECKBOX.
D: MODIFY LINE WITH CHECKBOX.
Ans:C

51. Which of the following is NOT a true statement in regard to a sorted internal table
type?
A: May only be accessed by its key.
B: Its key may be UNIQUE or NON-UNIQUE.
C: Entries are sorted according to its key when added.
D: A binary search is used when accessing rows by its key.
Ans: A

52. The following code indicates:
CALL SCREEN 9000 STARTING AT 10 5 ENDING AT 60 20
A: Screen 9000 is called with the cursor at coordinates (10,5)(60,20).
B: Screen 9000 must be of type "Modal dialog box."
C: Display screen 9000 in a full window.
D: Screen 9000 may only contain an ABAP list.
Ans:A

53. After a DESCRIBE TABLE statement SY-TFILL will contain
A: The number of rows in the internal table.
B: The current OCCURS value.
C: Zero, if the table contains one or more rows.
D: The length of the internal table row structure.
Ans:A

54. Function module source code may not call a subroutine.
A: True
B: False
Ans: B

55. This data type has a default length of eight and a default value = '00000000'.
A: P
B: D
C: N
D: C
Ans: B

56. Within the source code of a function module, errors are handled via the keyword:
A: EXCEPTION
B: RAISE
C: STOP
D: ABEND
Ans:B

57. Which of these is NOT a valid type of function module?
A: Normal
B: Update
C: RFC
D: Dialog
Ans:D

58. To call a local subroutine named calculate answer, use this line of code:
A: PERFORM calculate answer.
B: CALL calculate answer.
C: USING calculate answer.
D: SUB calculate answer.
Ans:A

59. Given:
DO.
Write: /1 'E equals MC squared.'.
ENDDO.
This will result in ____.
A: output of 'E equals MC squared.' on a new line one time
B: an endless loop that results in an abend error
C: output of 'E equals MC squared.' on a new line many times
D: a loop that will end when the user presses ESC
Ans.B

60. The following code indicates
write: /5 'I Love ABAP'.
A: Output 'I Lov' on the current line
B: Output 'I Love ABAP' starting at column 5 on the current line
C: Output 'I Lov' on a new line
D: Output 'I Love ABAP' starting at column 5 on a new line
Ans: D

61. Which of the following is NOT a component of the default standard ABAP report
header?
A: Date and Time
B: List title
C: Page number
D: Underline
Ans: A

62. A select statement has built-in authorization checks.
A: True
B: False
Ans:B

63. A BDC program is used for all of the following except:
A: Downloading data to a local file
B: Data interfaces between SAP and external systems
C: Initial data transfer
D: Entering a large amount of data
Ans:B

64. Page footers are coded in the event:
A: TOP-OF-PAGE.
B: END-OF-SELECTION.
C: NEW-PAGE.
D: END-OF-PAGE.
Ans:D

65. Page headers for a secondary/details list can be coded in the event:
A: GET.
B: INITIALIZATION.
C: TOP-OF-PAGE DURING LINE-SELECTION.
D: NEW-PAGE.
Ans:C

66. To both add or change lines of a database table, use ____.
A: INSERT
B: UPDATE
C: APPEND
D: MODIFY
Ans:D

67. To select one record for a matching primary key, use ____.
A: SELECT
B: SELECT INTO
C: SELECT SINGLE
D: SELECT ENTRY
Ans:C

68. After adding rows to an internal table with COLLECT, you should avoid adding
More rows with APPEND.
A: True
B: False
Ans:A

69. The output for the following code will be
report zabaprg.
DATA: my_field type I value 99.
my_field = my_field + 1.
clear my_field.
WRITE: 'The value is', my_field left-justified.
A: The value is 99
B: The value is 100
C: The value is 0
D: None of the above
Ans: C

70. If this code results in an error, the remedy is
SELECT * FROM tab1 WHERE fld3 = pfld3.
WRITE: /1 tab1-fld1, tab1-fld2.
ENDSELECT.
A: Add a SY-SUBRC check.
B: Change the * to fld1 fld2.
C: Add INTO (tab1-fld1, tab1-fld2).
D: There is no error.
Ans: C,D

71. To summarize the contents of several matching lines into a single line, use this
SELECT statement clause.
A: INTO
B: WHERE
C: FROM
D: GROUP BY
Ans:D

72. What is output by the following code?
DATA: BEGIN OF itab OCCURS 0,
letter type c,
END OF itab.
itab-letter = 'A'. APPEND itab.
itab-letter = 'B'. APPEND itab.
itab-letter = 'C'. APPEND itab.
itab-letter = 'D'. APPEND itab.
LOOP AT itab.
SY-TABIX = 2.
WRITE itab-letter.
EXIT.
ENDLOOP.
A: A
B: A B C D
C: B
D: B C D
Ans: A

73. All of the following are considered to be valid ABAP modularization techniques
except:
A: Subroutine
B: External subroutine
C: Field-group
D: Function module
Ans:C


74. To create a list of the top 25 customers, you should use
A: DELETE ADJACENT DUPLICATES
B: READ TABLE itab INDEX 25
C: LOOP AT itab FROM 25
D: APPEND SORTED BY
Ans:D

75. Which of these sentences most accurately describes the GET VBAK LATE. event?
A: This event is processed before the second time the GET VBAK event is
processed.
B: This event is processed after all occurrences of the GET VBAK event are
completed.
C: This event will only be processed after the user has selected a basic list row.
D: This event is only processed if no records are selected from table VBAK.
Ans:B

76. In an R/3 environment, where is the work of a dialog program performed?
A: On the application server using a dialog work process service.
B: On the presentation server using a dialog work process service.
C: On the database server using a dialog work process service.
D: None of the above.
Ans: A

77. In regard to Native SQL, which of the following is NOT a true statement?
A: A CONNECT to the database is done automatically.
B: You must specify the SAP client.
C: The tables that you address do not have to exist in the ABAP Dictionary.
D: Will run under different database systems.
Ans:D

78. To change one or more lines of a database table, use ____.
A: UPDATE
B: INSERT
C: INTO
D: MOD
Ans:A

79. Which is the correct sequence of events?
A: AT SELECTION-SCREEN, TOP-OF-PAGE, INITIALIZATION
B: START-OF-SELECTION, AT USER-COMMAND, GET dbtab
C: INITIALIZATION, END-OF-SELECTION, AT LINE-SELECTION
D: GET dbtab, GET dbtab LATE, START-OF-SELECTION
Ans:B

80. Which of the following is NOT a numeric data type?
A: I
B: N
C: P
D: F
Ans: B

Thursday, August 14, 2014

200 LATEST TOP JAVA Interview Questions and Answers

Below are the list of Latest Java interview questions and answers for freshers beginners and experienced pdf free download.

JAVA Interview Questions and Answers

JAVA Interview Questions and Answers
JAVA Interview Questions and Answers
Q: What do you know about Java?
A: Java is a high-level programming language originally developed by Sun Microsystems and released in 1995. Java runs on a variety of platforms, such as Windows, Mac OS, and the various versions of UNIX.

Q: What are the supported platforms by Java Programming Language?
A: Java runs on a variety of platforms, such as Windows, Mac OS, and the various versions of UNIX/Linux like HP-Unix, Sun Solaris, Redhat Linux, Ubuntu, CentOS, etc.

Q: List any five features of Java?
A: Some features include Object Oriented, Platform Independent, Robust, Interpreted, Multi-threaded

Q: Why is Java Architectural Neutral?
A: It’s compiler generates an architecture-neutral object file format, which makes the compiled code to be executable on many processors, with the presence of Java runtime system.

Q: How Java enabled High Performance?
A: Java uses Just-In-Time compiler to enable high performance. Just-In-Time compiler is a program that turns Java bytecode, which is a program that contains instructions that must be interpreted into instructions that can be sent directly to the processor.

Q: Why Java is considered dynamic?
A: It is designed to adapt to an evolving environment. Java programs can carry extensive amount of run-time information that can be used to verify and resolve accesses to objects on run-time.

Q: What is Java Virtual Machine and how it is considered in context of Java’s platform independent feature?
A: When Java is compiled, it is not compiled into platform specific machine, rather into platform independent byte code. This byte code is distributed over the web and interpreted by virtual Machine (JVM) on whichever platform it is being run.

Q: List two Java IDE’s?
A: Netbeans, Eclipse, etc.

Q: List some Java keywords(unlike C, C++ keywords)?
A: Some Java keywords are import, super, finally, etc.

Q: What do you mean by Object?
A: Object is a runtime entity and it’s state is stored in fields and behavior is shown via methods. Methods operate on an object's internal state and serve as the primary mechanism for object-to-object communication.

Q: Define class?
A: A class is a blue print from which individual objects are created. A class can contain fields and methods to describe the behavior of an object.

Q: What kind of variables a class can consist of?
A: A class consist of Local variable, instance variables and class variables.

Q: What is a Local Variable
A: Variables defined inside methods, constructors or blocks are called local variables. The variable will be declared and initialized within the method and it will be destroyed when the method has completed.

Q: What is a Instance Variable
A: Instance variables are variables within a class but outside any method. These variables are instantiated when the class is loaded.

Q: What is a Class Variable
A: These are variables declared with in a class, outside any method, with the static keyword.

Q: What is Singleton class?
A: Singleton class control object creation, limiting the number to one but allowing the flexibility to create more objects if the situation changes.

Q: What do you mean by Constructor?
A: Constructor gets invoked when a new object is created. Every class has a constructor. If we do not explicitly write a constructor for a class the java compiler builds a default constructor for that class.

Q: List the three steps for creating an Object for a class?
A: An Object is first declared, then instantiated and then it is initialized.

Q: What is the default value of byte datatype in Java?
A: Default value of byte datatype is 0.

Q: What is the default value of float and double datatype in Java?
A: Default value of float and double datatype in different as compared to C/C++. For float its 0.0f and for double it’s 0.0d

Q: When a byte datatype is used?
A: This data type is used to save space in large arrays, mainly in place of integers, since a byte is four times smaller than an int.

Q: What is a static variable?
A: Class variables also known as static variables are declared with the static keyword in a class, but outside a method, constructor or a block.

Q: What do you mean by Access Modifier?
A: Java provides access modifiers to set access levels for classes, variables, methods and constructors. A member has package or default accessibility when no accessibility modifier is specified.

Q: What is protected access modifier?
A: Variables, methods and constructors which are declared protected in a superclass can be accessed only by the subclasses in other package or any class within the package of the protected members' class.

Q: What do you mean by synchronized Non Access Modifier?
A: Java provides these modifiers for providing functionalities other than Access Modifiers, synchronized used to indicate that a method can be accessed by only one thread at a time.

Q: According to Java Operator precedence, which operator is considered to be with highest precedence?
A: Postfix operators i.e () [] . is at the highest precedence.

Q: Variables used in a switch statement can be used with which datatypes?
A: Variables used in a switch statement can only be a byte, short, int, or char.

Q: When parseInt() method can be used?
A: This method is used to get the primitive data type of a certain String.

Q: Why is String class considered immutable?
A: The String class is immutable, so that once it is created a String object cannot be changed. Since String is immutable it can safely be shared between many threads ,which is considered very important for multithreaded programming.

Q: Why is StringBuffer called mutable?
A: The String class is considered as immutable, so that once it is created a String object cannot be changed. If there is a necessity to make alot of modifications to Strings of characters then StringBuffer should be used.

Q: What is the difference between StringBuffer and StringBuilder class?
A: Use StringBuilder whenever possible because it is faster than StringBuffer. But, if thread safety is necessary then use StringBuffer objects.

Q: Which package is used for pattern matching with regular expressions?
A: java.util.regex package is used for this purpose.

Q: java.util.regex consists of which classes?
A: java.util.regex consists of three classes: Pattern class, Matcher class and PatternSyntaxException class.

Q: What is finalize() method?
A: It is possible to define a method that will be called just before an object's final destruction by the garbage collector. This method is called finalize( ), and it can be used to ensure that an object terminates cleanly.

Q: What is an Exception?
A: An exception is a problem that arises during the execution of a program. Exceptions are caught by handlers positioned along the thread's method invocation stack.

Q: What do you mean by Checked Exceptions?
A: It is an exception that is typically a user error or a problem that cannot be foreseen by the programmer. For example, if a file is to be opened, but the file cannot be found, an exception occurs. These exceptions cannot simply be ignored at the time of compilation.

Q: Explain Runtime Exceptions?
A: It is an exception that occurs that probably could have been avoided by the programmer. As opposed to checked exceptions, runtime exceptions are ignored at the time of compliation.

Q: Which are the two subclasses under Exception class?
A: The Exception class has two main subclasses : IOException class and RuntimeException Class.

Q: When throws keyword is used?
A: If a method does not handle a checked exception, the method must declare it using the throwskeyword. The throws keyword appears at the end of a method's signature.

Q: When throw keyword is used?
A: An exception can be thrown, either a newly instantiated one or an exception that you just caught, by using throw keyword.

Q: How finally used under Exception Handling?
A: The finally keyword is used to create a block of code that follows a try block. A finally block of code always executes, whether or not an exception has occurred.

Q: What things should be kept in mind while creating your own exceptions in Java?
A: While creating your own exception:

All exceptions must be a child of Throwable.

If you want to write a checked exception that is automatically enforced by the Handle or Declare Rule, you need to extend the Exception class.

You want to write a runtime exception, you need to extend the RuntimeException class.

Q: Define Inheritance?
A: It is the process where one object acquires the properties of another. With the use of inheritance the information is made manageable in a hierarchical order.

Q: When super keyword is used?
A: If the method overrides one of its superclass's methods, overridden method can be invoked through the use of the keyword super. It can be also used to refer to a hidden field

Q: What is Polymorphism?
A: Polymorphism is the ability of an object to take on many forms. The most common use of polymorphism in OOP occurs when a parent class reference is used to refer to a child class object.

Q: What is Abstraction?
A: It refers to the ability to make a class abstract in OOP. It helps to reduce the complexity and also improves the maintainability of the system.

Q: What is Abstract class
A: These classes cannot be instantiated and are either partially implemented or not at all implemented. This class contains one or more abstract methods which are simply method declarations without a body.

Q: When Abstract methods are used?
A: If you want a class to contain a particular method but you want the actual implementation of that method to be determined by child classes, you can declare the method in the parent class as abstract.

Q: What is Encapsulation?
A: It is the technique of making the fields in a class private and providing access to the fields via public methods. If a field is declared private, it cannot be accessed by anyone outside the class, thereby hiding the fields within the class. Therefore encapsulation is also referred to as data hiding.

Q: What is the primary benefit of Encapsulation?
A: The main benefit of encapsulation is the ability to modify our implemented code without breaking the code of others who use our code. With this Encapsulation gives maintainability, flexibility and extensibility to our code.

Q: What is an Interface?
A: An interface is a collection of abstract methods. A class implements an interface, thereby inheriting the abstract methods of the interface.

Q: Give some features of Interface?
A: It includes:

Interface cannot be instantiated

An interface does not contain any constructors.

All of the methods in an interface are abstract.

Q: Define Packages in Java?
A: A Package can be defined as a grouping of related types(classes, interfaces, enumerations and annotations ) providing access protection and name space management.

Q: Why Packages are used?
A: Packages are used in Java in-order to prevent naming conflicts, to control access, to make searching/locating and usage of classes, interfaces, enumerations and annotations, etc., easier.

Q: What do you mean by Multithreaded program?
A: A multithreaded program contains two or more parts that can run concurrently. Each part of such a program is called a thread, and each thread defines a separate path of execution.

Q: What are the two ways in which Thread can be created?
A: Thread can be created by: implementing Runnable interface, extending the Thread class.

Q: What is an applet?
A: An applet is a Java program that runs in a Web browser. An applet can be a fully functional Java application because it has the entire Java API at its disposal.

Q: An applet extend which class?
A: An applet extends java.applet.Applet class.

Q: Explain garbage collection in Java?
A: It uses garbage collection to free the memory. By cleaning those objects that is no longer reference by any of the program.

Q: Define immutable object?
A: An immutable object can’t be changed once it is created.

Q: Explain the usage of this() with constructors?
A: It is used with variables or methods and used to call constructer of same class.

Q: Explain Set Interface?
A: It is a collection of element which cannot contain duplicate elements. The Set interface contains only methods inherited from Collection and adds the restriction that duplicate elements are prohibited.

Q: Explain TreeSet?
A: It is a Set implemented when we want elements in a sorted order.

Q: What is Comparable Interface?
A: It is used to sort collections and arrays of objects using the collections.sort() and java.utils. The objects of the class implementing the Comparable interface can be ordered.

Q: Difference between throw and throws?
A: It includes:

Throw is used to trigger an exception where as throws is used in declaration of exception.

Without throws, Checked exception cannot be handled where as checked exception can be propagated with throws.

Q: Explain the following line used under Java Program:
public static void main (String args[ ])

A: The following shows the explanation individually:

public: it is the access specifier.

static: it allows main() to be called without instantiating a particular instance of a class.

void: it affirns the compiler that no value is returned by main().

main(): this method is called at the beginning of a Java program.

String args[ ]: args parameter is an instance array of class String

Q: Define JRE i.e. Java Runtime Environment?
A: Java Runtime Environment is an implementation of the Java Virtual Machine which executes Java programs. It provides the minimum requirements for executing a Java application;

Q: What is JAR file?
A: JAR files is Java Archive fles and it aggregates many files into one. It holds Java classes in a library. JAR files are built on ZIP file format and have .jar file extension.

Q: What is a WAR file?
A: This is Web Archive File and used to store XML, java classes, and JavaServer pages. which is used to distribute a collection of JavaServer Pages, Java Servlets, Java classes, XML files, static Web pages etc.

Q: Define JIT compiler?
A: It improves the runtime performance of computer programs based on bytecode.

Q: What is the difference between object oriented programming language and object based programming language?
A: Object based programming languages follow all the features of OOPs except Inheritance. JavaScript is an example of object based programming languages

Q: What is the purpose of default constructor?
A: The java compiler creates a default constructor only if there is no constructor in the class.

Q: Can a constructor be made final?
A: No, this is not possible.

Q: What is static block?
A: It is used to initialize the static data member, It is excuted before main method at the time of classloading.

Q: Define composition?
A: Holding the reference of the other class within some other class is known as composition.

Q: What is function overloading?
A: If a class has multiple functions by same name but different parameters, it is known as Method Overloading.

Q: What is function overriding?
A: If a subclass provides a specific implementation of a method that is already provided by its parent class, it is known as Method Overriding.

Q: Difference between Overloading and Overriding?
A: Method overloading increases the readability of the program. Method overriding provides the specific implementation of the method that is already provided by its super class parameter must be different in case of overloading, parameter must be same in case of overriding.

Q: What is final class?
A: Final classes are created so the methods implemented by that class cannot be overridden. It can’t be inherited.

Q: What is NullPointerException?
A: A NullPointerException is thrown when calling the instance method of a null object, accessing or modifying the field of a null object etc.

Q: What are the ways in which a thread can enter the waiting state?
A: 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.

Q: How does multi-threading take place on a computer with a single CPU?
A: The operating system's task scheduler allocates execution time to multiple tasks. By quickly switching between executing tasks, it creates the impression that tasks execute sequentially.

Q: What invokes a thread's run() method?
A: After a thread is started, via its start() method of the Thread class, the JVM invokes the thread's run() method when the thread is initially executed.

Q: Does it matter in what order catch statements for FileNotFoundException and IOException are written?
A: Yes, it does. The FileNoFoundException is inherited from the IOException. Exception's subclasses have to be caught first.

Q: What is the difference between yielding and sleeping?
A: When a task invokes its yield() method, it returns to the ready state. When a task invokes its sleep() method, it returns to the waiting state.

Q: Why Vector class is used?
A: The Vector class provides the capability to implement a growable array of objects. Vector proves to be very useful if you don't know the size of the array in advance, or you just need one that can change sizes over the lifetime of a program.

Q: How many bits are used to represent Unicode, ASCII, UTF-16, and UTF-8 characters?
A: Unicode requires 16 bits and ASCII require 7 bits. Although the ASCII character set uses only 7 bits, it is usually represented as 8 bits. UTF-8 represents characters using 8, 16, and 18 bit patterns. UTF-16 uses 16-bit and larger bit patterns.

Q: What are Wrapper classes?
A: These are classes that allow primitive types to be accessed as objects. Example: Integer, Character, Double, Boolean etc.

Q: What is the difference between a Window and a Frame?
A: The Frame class extends Window to define a main application window that can have a menu bar.

Q: Which package has light weight components?
A: javax.Swing package. All components in Swing, except JApplet, JDialog, JFrame and JWindow are lightweight components.

Q: What is the difference between the paint() and repaint() methods?
A: The paint() method supports painting via a Graphics object. The repaint() method is used to cause paint() to be invoked by the AWT painting thread.

Q: What is the purpose of File class?
A: It is used to create objects that provide access to the files and directories of a local file system.

Q: What is the difference between the Reader/Writer class hierarchy and the InputStream/OutputStream class hierarchy?
A: The Reader/Writer class hierarchy is character-oriented, and the InputStream/OutputStream class hierarchy is byte-oriented.

Q: Which class should you use to obtain design information about an object?
A: The Class class is used to obtain information about an object's design and java.lang.Class class instance represent classes, interfaces in a running Java application.

Q: What is the difference between static and non-static variables?
A: A static variable is associated with the class as a whole rather than with specific instances of a class. Non-static variables take on unique values with each object instance.

Q: What is Serialization and deserialization?
A: Serialization is the process of writing the state of an object to a byte stream. Deserialization is the process of restoring these objects.

Q: What are use cases?
A: It is part of the analysis of a program and describes a situation that a program might encounter and what behavior the program should exhibit in that circumstance.

Q: Explain the use of sublass in a Java program?
A: Sub class inherits all the public and protected methods and the implementation. It also inherits all the default modifier methods and their implementation.

Q: How to add menushortcut to menu item?
A: If there is a button instance called b1, you may add menu short cut by calling b1.setMnemonic('F'), so the user may be able to use Alt+F to click the button.

Q: Can you write a Java class that could be used both as an applet as well as an application?
A: Yes, just add a main() method to the applet.

Q: What is the difference between Swing and AWT components?
A: AWT components are heavy-weight, whereas Swing components are lightweight. Heavy weight components depend on the local windowing toolkit. For example, java.awt.Button is a heavy weight component, when it is running on the Java platform for Unix platform, it maps to a real Motif button.

Q: What's the difference between constructors and other methods?
A: Constructors must have the same name as the class and can not return a value. They are only called once while regular methods could be called many times.

Q: Is there any limitation of using Inheritance?
A: Yes, since inheritance inherits everything from the super class and interface, it may make the subclass too clustering and sometimes error-prone when dynamic overriding or dynamic overloading in some situation.

Q: When is the ArrayStoreException thrown?
A: When copying elements between different arrays, if the source or destination arguments are not arrays or their types are not compatible, an ArrayStoreException will be thrown.

Q: Can you call one constructor from another if a class has multiple constructors?
A: Yes, use this() syntax.

Q: What's the difference between the methods sleep() and wait()?
A: The code sleep(2000); puts thread aside for exactly two seconds. The code wait(2000), causes a wait of up to two second. A thread could stop waiting earlier if it receives the notify() or notifyAll() call. The method wait() is defined in the class Object and the method sleep() is defined in the class Thread.

Q: When ArithmeticException is thrown?
A: The ArithmeticException is thrown when integer is divided by zero or taking the remainder of a number by zero. It is never thrown in floating-point operations.

Q: What is a transient variable?
A: A transient variable is a variable that may not be serialized during Serialization and which is initialized by its default value during de-serialization,

Q: What is synchronization?
A: Synchronization is the capability to control the access of multiple threads to shared resources. synchronized keyword in java provides locking which ensures mutual exclusive access of shared resource and prevent data race.

Q: What is the Collections API?
A: The Collections API is a set of classes and interfaces that support operations on collections of objects.

Q: Does garbage collection guarantee that a program will not run out of memory?
A: Garbage collection does not guarantee that a program will not run out of memory. It is possible for programs to use up memory resources faster than they are garbage collected. It is also possible for programs to create objects that are not subject to garbage collection.

Q: The immediate superclass of the Applet class?
A: Panel is the immediate superclass. A panel provides space in which an application can attach any other component, including other panels.

Q: Which Java operator is right associative?
A: The = operator is right associative.

Q: What is the difference between a break statement and a continue statement?
A: A break statement results in the termination of the statement to which it applies (switch, for, do, or while). A continue statement is used to end the current loop iteration and return control to the loop statement.

Q: If a variable is declared as private, where may the variable be accessed?
A: A private variable may only be accessed within the class in which it is declared.

Q: What is the purpose of the System class?
A: The purpose of the System class is to provide access to system resources.

Q: List primitive Java types?
A: The eight primitive types are byte, char, short, int, long, float, double, and boolean.

Q: What is the relationship between clipping and repainting under AWT?
A: When a window is repainted by the AWT painting thread, it sets the clipping regions to the area of the window that requires repainting.

Q: Which class is the immediate superclass of the Container class?
A: Component class is the immediate super class.

Q: What class of exceptions are generated by the Java run-time system?
A: The Java runtime system generates RuntimeException and Error exceptions.

Q: Under what conditions is an object's finalize() method invoked by the garbage collector?
A: The garbage collector invokes an object's finalize() method when it detects that the object has become unreachable.

Q: How can a dead thread be restarted?
A: A dead thread cannot be restarted.

Q: Which arithmetic operations can result in the throwing of an ArithmeticException?
A: Integer / and % can result in the throwing of an ArithmeticException.

Q: Variable of the boolean type is automatically initialized as?
A: The default value of the boolean type is false.

Q: Can try statements be nested?
A: Yes

Q: What are ClassLoaders?
A: A class loader is an object that is responsible for loading classes. The class ClassLoader is an abstract class.

Q: What is the difference between an Interface and an Abstract class?
A: An abstract class can have instance methods that implement a default behavior. An Interface can only declare constants and instance methods, but cannot implement default behavior and all methods are implicitly abstract. An interface has all public members and no implementation.

Q: What will happen if static modifier is removed from the signature of the main method?
A: Program throws "NoSuchMethodError" error at runtime .

Q: What is the default value of an object reference declared as an instance variable?
A: Null, unless it is defined explicitly.

Q: Can a top level class be private or protected?
A: No, a top level class can not be private or protected. It can have either "public" or no modifier.

Q: Why do we need wrapper classes?
A: We can pass them around as method parameters where a method expects an object. It also provides utility methods.

Q: What is the difference between error and an exception?
A: An error is an irrecoverable condition occurring at runtime. Such as OutOfMemory error. Exceptions are conditions that occur because of bad input etc. e.g. FileNotFoundException will be thrown if the specified file does not exist.

Q: Is it necessary that each try block must be followed by a catch block?
A: It is not necessary that each try block must be followed by a catch block. It should be followed by either a catch block or a finally block.

Q: When a thread is created and started, what is its initial state?
A: A thread is in the ready state as initial state after it has been created and started.

Q: What is the Locale class?
A: The Locale class is used to tailor program output to the conventions of a particular geographic, political, or cultural region.

Q: What are synchronized methods and synchronized statements?
A: Synchronized methods are methods that are used to control access to an object. A synchronized statement can only be executed after a thread has acquired the lock for the object or class referenced in the synchronized statement.

Q: What is runtime polymorphism or dynamic method dispatch?
A: Runtime polymorphism or dynamic method dispatch is a process in which a call to an overridden method is resolved at runtime rather than at compile-time. In this process, an overridden method is called through the reference variable of a superclass.

Q: What is Dynamic Binding(late binding)?
A: Binding refers to the linking of a procedure call to the code to be executed in response to the call. Dynamic binding means that the code associated with a given procedure call is not known until the time of the call at run-time.

Q: Can constructor be inherited?
A: No, constructor cannot be inherited.

Q: What are the advantages of ArrayList over arrays?
A: ArrayList can grow dynamically and provides more powerful insertion and search mechanisms than arrays.

Q: Why deletion in LinkedList is fast than ArrayList?
A: Deletion in linked list is fast because it involves only updating the next pointer in the node before the deleted node and updating the previous pointer in the node after the deleted node.

Q: How do you decide when to use ArrayList and LinkedList?
A: If you need to frequently add and remove elements from the middle of the list and only access the list elements sequentially, then LinkedList should be used. If you need to support random access, without inserting or removing elements from any place other than the end, then ArrayList should be used.

Q: What is a Values Collection View ?
A: It is a collection returned by the values() method of the Map Interface, It contains all the objects present as values in the map.

Q: What is dot operator?
A: The dot operator(.) is used to access the instance variables and methods of class objects.It is also used to access classes and sub-packages from a package.

Q: Where and how can you use a private constructor?
A: Private constructor is used if you do not want other classes to instantiate the object and to prevent subclassing.T

Q: What is type casting?
A: Type casting means treating a variable of one type as though it is another type.

Q: Describe life cycle of thread?
A: A thread is a execution in a program. The life cycle of a thread include:
  • Newborn state
  • Runnable state
  • Running state
  • Blocked state
  • Dead state
Q: What is the difference between the >> and >>> operators?
A: The >> operator carries the sign bit when shifting right. The >>> zero-fills bits that have been shifted out.

Q: Which method of the Component class is used to set the position and size of a component?
A: setBounds() method is used for this purpose.

Q: What is the range of the short type?
A: The range of the short type is -(2^15) to 2^15 - 1.

Q: What is the immediate superclass of Menu?
A: MenuItem class

Q: Does Java allow Default Arguments?
A: No, Java does not allow Default Arguments.

Q: Which number is denoted by leading zero in java?
A: Octal Numbers are denoted by leading zero in java, example: 06

Q: Which number is denoted by leading 0x or 0X in java?
A: Hexadecimal Numbers are denoted by leading 0x or 0X in java, example: 0XF

Q: Break statement can be used as labels in Java?
A: Yes, an example can be break one;

Q: Where import statement is used in a Java program?
A: Import statement is allowed at the beginning of the program file after package statement.

Q: Explain suspend() method under Thread class>
A: It is used to pause or temporarily stop the execution of the thread.

Q: Explain isAlive() method under Thread class?
A: It is used to find out whether a thread is still running or not.

Q: What is currentThread()?
A: It is a public static method used to obtain a reference to the current thread.

Q: Explain main thread under Thread class execution?
A: The main thread is created automatically and it begins to execute immediately when a program starts. It ia thread from which all other child threads originate.

Q: Life cycle of an applet includes which steps?
A: Life cycle involves the following steps:
  • Initialization
  • Starting
  • Stopping
  • Destroying
  • Painting
Q: Why is the role of init() method under applets?
A: It initializes the applet and is the first method to be called.

Q: Which method is called by Applet class to load an image?
A: getImage(URL object, filename) is used for this purpose.

Q: Define code as an attribute of Applet?
A: It is used to specify the name of the applet class.

Q: Define canvas?
A: It is a simple drawing surface which are used for painting images or to perform other graphical operations.

Q: Define Network Programming?
A: It refers to writing programs that execute across multiple devices (computers), in which the devices are all connected to each other using a network.

Q: What is a Socket?
A: Sockets provide the communication mechanism between two computers using TCP. A client program creates a socket on its end of the communication and attempts to connect that socket to a server.

Q: Advantages of Java Sockets?
A: Sockets are flexible and sufficient. Efficient socket based programming can be easily implemented for general communications. It cause low network traffic.

Q: Disadvantages of Java Sockets?
A: Socket based communications allows only to send packets of raw data between applications. Both the client-side and server-side have to provide mechanisms to make the data useful in any way.

Q: Which class is used by server applications to obtain a port and listen for client requests?
A: java.net.ServerSocket class is used by server applications to obtain a port and listen for client requests

Q: Which class represents the socket that both the client and server use to communicate with each other?
A: java.net.Socket class represents the socket that both the client and server use to communicate with each other.

Q: Why Generics are used in Java?
A: Generics provide compile-time type safety that allows programmers to catch invalid types at compile time. Java Generic methods and generic classes enable programmers to specify, with a single method declaration, a set of related methods or, with a single class declaration, a set of related types.

Q: What environment variables do I need to set on my machine in order to be able to run Java programs?
A: CLASSPATH and PATH are the two variables.

Q: Is there any need to import java.lang package?
A: No, there is no need to import this package. It is by default loaded internally by the JVM.

Q: What is Nested top-level class?
A: If a class is declared within a class and specify the static modifier, the compiler treats the class just like any other top-level class. Nested top-level class is an Inner class.

Q: What is Externalizable interface?
A: Externalizable is an interface which contains two methods readExternal and writeExternal. These methods give you a control over the serialization mechanism.

Q: If System.exit (0); is written at the end of the try block, will the finally block still execute?
A: No in this case the finally block will not execute because when you say System.exit (0); the control immediately goes out of the program, and thus finally never executes.

Q: What is daemon thread?
A: Daemon thread is a low priority thread, which runs intermittently in the back ground doing the garbage collection operation for the java runtime system.

Q: Which method is used to create the daemon thread?
A: setDaemon method is used to create a daemon thread.

Q: Which method must be implemented by all threads?
A: All tasks must implement the run() method

Q: What is the GregorianCalendar class?
A: The GregorianCalendar provides support for traditional Western calendars

Q: What is the SimpleTimeZone class?
A: The SimpleTimeZone class provides support for a Gregorian calendar .

Q: What is the difference between the size and capacity of a Vector?
A: The size is the number of elements actually stored in the vector, while capacity is the maximum number of elements it can store at a given instance of time.

Q: Can a vector contain heterogenous objects?
A: Yes a Vector can contain heterogenous objects. Because a Vector stores everything in terms of Object.

Q: What is an enumeration?
A: An enumeration is an interface containing methods for accessing the underlying data structure from which the enumeration is obtained. It allows sequential access to all the elements stored in the collection.

Q: What is difference between Path and Classpath?
A: Path and Classpath are operating system level environment variales. Path is defines where the system can find the executables(.exe) files and classpath is used to specify the location of .class files.

Q: Can a class declared as private be accessed outside it's package?
A: No, it's not possible to accessed outside it's package.

Q: What are the restriction imposed on a static method or a static block of code?
A: A static method should not refer to instance variables without creating an instance and cannot use "this" operator to refer the instance.

Q: Can an Interface extend another Interface?
A: Yes an Interface can inherit another Interface, for that matter an Interface can extend more than one Interface.

Q: Which object oriented Concept is achieved by using overloading and overriding?
A: Polymorphism

Q: What is an object's lock and which object's have locks?
A: An object's lock is a mechanism that is used by multiple threads to obtain synchronized access to the object. A thread may execute a synchronized method of an object only after it has acquired the object's lock.

Q: What is Downcasting?
A: It is the casting from a general to a more specific type, i.e. casting down the hierarchy.

Q: What are order of precedence and associativity and how are they used?
A: 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.

Q: If a method is declared as protected, where may the method be accessed?
A: A protected method may only be accessed by classes or interfaces of the same package or by subclasses of the class in which it is declared.

Q: What is the difference between inner class and nested class?
A: When a class is defined within a scope of another class, then it becomes inner class. If the access modifier of the inner class is static, then it becomes nested class.

Q: What restrictions are placed on method overriding?
A: Overridden methods must have the same name, argument list, and return type. The overriding method may not limit the access of the method it overrides.

Q: What is constructor chaining and how is it achieved in Java?
A: A child object constructor always first needs to construct its parent. In Java it is done via an implicit call to the no-args constructor as the first statement.

Q: Can a double value be cast to a byte?
A: Yes, a double value can be cast to a byte.

Q: How does a try statement determine which catch clause should be used to handle an exception?
A: When an exception is thrown within the body of a try statement, the catch clauses of the try statement are examined in the order in which they appear. The first catch clause that is capable of handling the exception is executed. The remaining catch clauses are ignored.

Q: What will be the default values of all the elements of an array defined as an instance variable?
A: If the array is an array of primitive types, then all the elements of the array will be initialized to the default value corresponding to that primitive type.