Adv Java
Programming

1. What Is the Java Technology 2. Points to keep in mind for pyramid. 3. Java Pyramid Program on type 1 4. Java Pyramid Program on type 2 5. Java Pyramid Programs on Type 3 6. Java Pyramid Programs on type 4 7. Java Pyramid Programs on type 5 8. Classes and Objects 9. Recursive functions 10. Constructors in Java 11. Method Overloading 12. Constructor Overloading 13. Inheritance in Java 14. Interface in Java 15. Method Overriding and Hiding Method 16. The final keyword 17. Exception Handling 18. Properties, System & Runtime Class in Java 19. Building Java GUI 20. Layout Managers 21. Menu Bar 22. Applets 23. Threading 24. Java Netwoking 25. Programs for Science and Engineer 26. Prg to demonstrate pre and post increment 27. Prg to convert Farenheit to Celsius temperature 28. Prg to convert kilogram to different units 29. Prg to calculate surface area and volume of sphere 30. Prg to calculate frequency 31. Prg to determine co-ordinate points 32. Prg to determine Equilateral, Isosceles or Scalene triangle 33. Prg to demonstrate conditional operator 34. Prg to calculate Final and initial interest amount 35. Prg to separate entered number 36. Prg to examine while loops and conditions 37. Prg to calculate number of year 38. Prg to find Armstrong number or not 39. Prg to find all Armstrong number 40. Prg to find limited Armstrong number 41. Prg to find Armstrong number using user defined function 42. Prg to find frequency of student 43. Prg to find maximum and minimum number 44. Prg to print number triangle 45. Prg to print vertical number triangle 46. Prg to print number triangle 47. Prg to print binary right angle triangle 48. Prg to print * triangle 49. Prg to to print rhombus 50. Prg to print entered number triangle 51. Prg to to find nCr and nPr 52. Prg to enter an element in array 53. Prg to sort number using array 54. Prg to find the position of element in array 55. Prg to find the position of element in array using boolean flag 56. Prg to add one extra element in an array 57. Prg to find the equation of line 58. Prg to find the common element from two array 59. Prg to find the highest scorer 60. Prg to create a square of number 61. Prg to create Pascal triangle 62. Prg to subtraction, multiplication and division using methods and classes 63. Prg to determine salary grade 64. Prg for complex number 65. Prg to calculate area 66. Prg for Greatest Common Divisior 67. Prg for displaying studenta mark sheet 68. Prg for demonstrating inheritance 69. Prg to calculate area of triangle 70. Prg for calculating volume of sphere or hemisphere 71. Prg for demonstrate classes 72. Prg for employee details 73. Prg for demonstrating super and base class 74. Prg for Bank Account 75. Prg for professor and student details 76. Prg for Addition, Multiplication and finding Transpose of two matrix 77. Prg for counting number of words in a string 78. Prg to count number of vowels and consonants in a string 79. Prg to fine number of upper case, lower case, white spaces and digit in a string 80. Prg to fine number of upper case, lower case, white spaces and digit in a string without inbuilt function 81. Prg to arrange a string in alphabetic order 82. Prg to count the number of character occurrence in a string 83. Prg to find the string length and character position 84. Prg for converting first character of word into upper case 85. Prg for demonstrating vectors for manipulating records 86. Prg for manupulting items record using vectors 87. Prg for bank transaction 88. Prg for counting number of days between any two different date 89. Prg for exception handling 90. Prg for throwing exception 91. Prg for exception 92. Prg to throw exception when number is invalid 93. Prg for renaming the current thread 94. Prg for demonstrating strat method of thread 95. Prg to demonstrate sleep and and join method of thread 96. Prg to demonstrate yield method of thread 97. Prg for demonstrating thread in class inheritance 98. Threading program using runnable interface 99. Thread program using sleep 100. Java Applet program for creating fancy round eye 101. Java Applet program for creating fancy face 102. Java Applet program for drawing string 103. Java Applet program for creating fancy face 104. Java Applet program for displaying fancy fonts 105. Java Applet program for drawing and filling rectangle 106. Java Applet program for creating house 107. Java Applet program to show lifecycle of applet 108. Java Applet program for creating polygon 109. Java Applet program for creating rectangle 110. Java Applet program for drawing line 111. Java Applet program for getting applet width and height 112. Interview Question & Answer part 1 113. Interview Question & Answer part 2 114. Interview Question & Answer part 3 115. Interview Question & Answer part 4 116. Interview Question & Answer part 5 117. Interview Question & Answer part 6 118. Interview Question & Answer part 7 119. Interview Question & Answer part 8 120. Interview Question & Answer part 9 121. Interview Question & Answer part 10 122. Interview Question & Answer part 11
Pr.Pg Next Pg

JAVA Interview Questions and Answers Part 1

 

1. Explain JAVA?

  • Java programming language and environment was designed to solve number of problems in modern programming practice.

  • Java was developed at Sun Microsystems, by James Gosling and released in 1995 as core component of Sun Microsystems.

  • Java changed the face of programming environment and gave a new definition to OOPS (Object Oriented Programming)

  • The Primary goal for creation of the Java is:

    1. It is Simple

    2. It is object-oriented

    3. It is independent of host platform

    4. It contains language facilities and library for networking

    5. It is designed to execute code from remote securely.

2. Features of JAVA?

  • The following features of JAVA are such as:

  • Simple: Java is Easy to write and more readable and eye catching.

  • Object Oriented: Java is a pure Object oriented. everything in java is object. All programs and data reside inside objects and classes

  • Platform-Independent: This technique unlike many other programming languages including C and C++ when Java is compiled, it is not compiled into platform specific machine. Java create platform independent byte code

  • Secure: While Java's secure feature it enables to develop virus-free, tamper-free systems.

  • Portable: Java programs can be run on any platform (Linux, Window, Mac)

  • Robust: The Code of java is Robust and Means of first checks the reliability of the code before Execution When We trying to Convert the Higher data type into the Lower Then it Checks the Demotion of the Code the It Will Warns a User to Not to do this So it is called as Robust

  • Multi-threaded: With Java's multi-threaded feature, it is possible to write programs that can do many tasks simultaneously.

  • High Performance: The use of bytecode makes the performance high. the speed is also high with comparing c, c++.

  • Dynamic: Java is a dynamic language. So it is capable of linking dynamic new classes, methods and objects

 

3. Types of variables in Java? Exaplain.

  • Local variables

  • Instance variables

  • Class/static variables

  1. Local variables:

    • Similar to how an object stores its state in fields, a method will often store its temporary state in local variables. The syntax for declaring a local variable is similar to declaring a field (for example, int count = 0;).

    • There is no special keyword designating a variable as local; that determination comes entirely from the location in which the variable is declared ó which is between the opening and closing braces of a method. As such, local variables are only visible to the methods in which they are declared; they are not accessible from the rest of the class.

  2. Instance variables:

    • Objects store their individual states in "non-static fields", that is, fields declared without the static keyword.Non-static fields are also known as instance variables because their values are unique to each instance of a class

  3. Class/static variables:

    • These variables are declared at the top level. They begin their life when first class loaded into memory and ends when class is unloaded. As they remain in memory till classes exist, so these variables often called Class variables. There only one copy of these variables exist

    • These variables are having highest scope that is they can be accessed from any method/ block in a class. When no explicit assignment made while declaration they are initialized to default values , depending on their type.

4. How to declare variables in JAVA?

  • declare single variable:

Syntax:

datatype <variable name>;

 

Example:

int x; // This will declares x as int data type.

char sex; //This will declares sex as char data type.

float perc; // This will declare perc as float data type.

 

  • Way to declare more than one variable having same datatype:

Syntax:

datatype <variable1>, <variable2>Ö<variable n>;

 

Example:

int x, y, z; // This will declare x,y,z variable as int data type.

float perc1, perc2;// This will declare perc1 and perc2 variables as float data type.

char dept1, dept2; // This will declare dept1 and dept2 variables as char data type.

 

5. What is Scanner class in JAVA?

  • A simple text scanner which can parse primitive types and strings using regular expressions

  • A Scanner breaks its input into tokens using a delimiter pattern, which by default matches whitespace.

  • The resulting tokens may then be converted into values of different types using the various next methods.

  • If you want to read a number then the Java code will look like below:

Scanner sc = new Scanner(System.in);

int i = sc.nextInt();

 

6. Explain String in JAVA?

  • In Java you can use strings as array of characters, however, more common practice is to use the String keyword to declare a string variable.

  • You can create string object using one of the following methods:

    1. By assigning a string literal to a String variable

    2. By using a String class constructor

    3. By using the string concatenation operator (+)

    4. By retrieving a property or calling a method that returns a string

    5. By calling a formatting method to convert a value or object to its string representation

  • A string can be declared and initialized in following way:

String s = "Sam";

 

7. What is the Java API?

  • The Java API is a large collection of ready-made software components that provide many useful capabilities, such as graphical user interface (GUI) widgets.

 

8. What is the Java Virtual Machine (JVM)?

  • The Java Virtual Machine is software that can be ported onto various hardware-based platforms.


9. What is the difference between a String and a StringBuffer class?

  • String is immutable : you canít modify a string object but can replace it by creating a new instance. Creating a new instance is rather expensive.

  • StringBuffer is mutable : use StringBuffer or StringBuilder when you want to modify the contents. StringBuilder was added in Java 5 and it is identical in all respects to StringBuffer except that it is not synchronized,which makes it slightly faster at the cost of not being thread-safe.

 

10. What is an abstract class?

  • Abstract class must be extended/subclassed (to be useful). It serves as a template. A class that is abstract may not be instantiated (ie. you may not call its constructor), abstract class may contain static data.

  • Any class with an abstract method is automatically abstract itself, and must be declared as such. A class may be declared abstract even if it has no abstract methods. This prevents it from being instantiated.

Pr.Pg border                                              Next Pg