What is Difference between dynamic polymorphism and static polymorphism with example?
Static polymorphism is used the concept of early binding or we can say
compile time binding where as dynamic polymorphism used the concept of
late binding or run time binding.
Anusha means "Following desires" or "stars" in Indian. It stems from a word which means "Breaking Dawn" or "Beautiful Morning".
How can you identify a constructor from among any other methods in a class?
Constructors have the same identifier as that of the class, so if the name of your class is Book then your constructor must also be named Book. Constructors have no return type, not even void.
What are nested Try-Catch in java?
A Nested Try Catch statement is nothing but a Try catch block inside either the Try or Catch or Finally block of an existing try-catch block.
Ex:
try {
...
try {
...
} catch (Exception ex) {
...
} finally {
...
}
} catch (Exception e){
...
} finally {
...
}
Example of ATM program in java?
1. Connect to a server
2. Log on the customer
3. Log out the customer
4. Disconnect from the server
What is a platform dependent language?
There is no such thing as a platform-free programming language. The correct term is platform-independent language. It simply means that the same source code can be compiled or interpreted upon any platform; the code is not machine-dependent.
What is a compiled program that runs on the client?
The program that runs on the client computer is the client program. Web-browser is a prominent example for client program.
Largest palindrome substring of a string?
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Vector; /**
*
*/ /**
* @author omnipath
*
*/
public class Palindrome { /**
* @param args
*/
public static void main(String[] args) { // open up standard input
BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String string = null; // readLine() method try { string = br.readLine(); } catch (IOException ioe) { System.out.println("IO error trying to read input!"); System.exit(1); }
Palindrome palindromeCase = new Palindrome(string);
System.out.println("The longest palindrome is: " + palindromeCase.palindrome);
System.out.println("The length of the longest palindrome is: " + palindromeCase.palindrome.length());
System.out.println("Counter is: " + palindromeCase.PalindromeCounter);
} String originalString;
String palindrome;
Vector vectPalindromes;
int palindromeLength;
int PalindromeCounter; public Palindrome(String s) {
PalindromeCounter = 0;
this.palindrome = "";
this.palindromeLength = this.palindrome.length();
this.originalString = s;
this.calculateLongestPalindrome(s);
} public void calculateLongestPalindrome(String s) {
if (s.length() == 1) {
this.palindrome = this.originalString;
this.palindromeLength = this.palindrome.length();
} this.parseForPalindrome(this.originalString); } public void parseForPalindrome(String s) {
PalindromeCounter++;
if (s.length() -1; i--) {
sb.append(s.charAt(i));
}
return sb.toString();
}
}
How do we pass array to function of java?
Let the function be private void processArray(int[] arInts); to call this 1. Create a local array variable, set the values and pass it int[] arIntInp = {0,1,3}; processArray(arIntInp); 2. Create an array on the fly and pass it processArray(new int[]{0,9});
C plus plus supports more object oriented Programming features as compared to JAVA?
No. Java is 100% OOP while C++ supports the concept of primitives (which it inherited from C). Thus C++ supports far more features than Java, but it does not support any more OOP features than Java. Note that there are only four primary OOP features: encapsulation, abstraction, inheritance and polymorphism. Anything beyond that is implementation-specific and outwith the scope of OOP.
What is the difference local applet and remote applet?
A LOCAL applet is the one which is stored on our computer system.when browser try to access the applet, it is not necessary for our computer to be connected to The Internet. A REMOTE applet is the one which is not stored on our computer system and we are required to be connected to the Internet. PARITOSH Khanna Happy Programing
What are the differences between objects and classes in java?
A class is basically a definition, and contains the object's code. An object is an instance of a class. For instance, there is one java.lang.String class, but you can instantiate any number of distinct java.lang.String objects (instances). While a class defines the instance variables than an object has, the instantiated object itself actually contains those variables. So to put it simply: An object is an instance of a class.
Why we can't use super and this keywords in the same constructor?
because, the super refers to the constructor of the parent class while this refers to the constructor of the current class. Either statements must be the first line in a constructor. So, since we cannot have two first lines in a method we cannot have both keywords in the same constructor.
public RandomTest() {
super();
this();
}
The above code will never compile. Even if we flip the positions of super and this, we will get the same compilation error.
What does the word part void mean?
void basically signifies that the method will not have a return value.
Explain different types of comment line in JAVA?
// The first type of comment is the single-line comment. // The single-line comment is denoted by a double slash. /* The next type of comment begins with a slash-asterisk, and ends with an asterisk-slash. It is often called a multi-line comment because it can span multiple lines with only one start indicator (/*) and one ending indicator (*/) */ /** * The last type of comment is the Javadoc comment. This * comment type has some guidelines that allows a Javadoc * reader to display information about a Java method or class * by using special tags: * * @param myNum - describe what the parameter myNum is used for * @return - describe what this method returns */ public static int doStuff(int myNum){}
How do you compare 2 lists in java?
First we need to have two lists whcih we need to compare.
and try to incorporate it in below code :
import java.util.*;
public class ExampleTry {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
List
al1.add("a1");
al1.add("a2");
al1.add("a3");
List
al2.add("a1");
al2.add("a2");
al2.add("a3");
al2.add("a4");
al2.add("a5");
for(Object objList:al1){
if(al2.contains(objList)){
al2.remove(objList);
}
}
System.out.println("Value in list"+al2);
}
}
Output :
Value in list[a4, a5]
Code to add 2 integer numbers without using int float and double?
int num1 = 1;
int num2 = 50;
int addition = num1 + num2;
Which keyword is used to declare constants and variable?
Constants are defines using the final keyword.
Variables are defined using the one of the keywords:
char
boolean
int
double
longint
String
To use a constant you would have to put in something like
double final pi = 3.14;
What is a Boolean or logical data type is used to store?
A Boolean or logical data type can be used to store anything that can answer a "yes/no" question. In other words, anything that has two options. For example:
Firstly you would need to get the user input and initialize some variables (This is all done in C#):
string text = Console.ReadLine();
int numberOfEven = 0;
int numberOfOdd = 0;
int numberOfZero = 0;
int number = 0;
Then you would need to loop through the string to see for the odd and even numbers:
while(number < text.Length) // Loops through how many times there are // numbers in the string
{
if (text[number] 0) // Just like the one before, checks if it is // odd
{
numberOfOdd ++;
}
number ++;
}
And you can print off each of the integers to get how many evens, odds and zeros there are.
Static method can be overridden?
Depends. A non-static method that is declared final cannot be overridden. A non-static method in a final class cannot be overridden. A non-static method that is declared private cannot be overridden. A non-static method that is declared with package visibility cannot be overridden by classes in a different package.
Other than that, yes.
How do you make an program in object oriented programming?
Object Oriented Programming is the technique to create programs based on the real world..object oriented programming model programs are organized around objects and data rather than actions and logic. In OOP based language the principal aim is to find out the objects to manipulate and their relation between each other.OOP offers greater flexibility and compatibility and is popular in developing larger application.
What is inheritance explain with an example?
Inheritance is a feature in Java wherein one class will inherit or use the features of another class.
Ex: public class A extends B {
…
}
Here class A is the child class and B the parent. The child inherits the features/methods of the parent and can use them.
A variable data is anything that won't necessarily be the same every time you run a computer program. It may come from user input, from a random function, from consulting a database, etc.