All object-oriented programming languages must have the 3 following features?
Abstraction, encapsulation and polymorphismare the three fundamental features of an object oriented programming language.
What was the original name for Java?
First when it was developed , it was named as Oak , then after sometime its name changed to Green , finally it is renamed as "Java" from Java Coffee . It is also said that a lot of this coffee was consumed by java creators at that time .
Java program that convert infix notation to prefix notation?
The following class should convert prefix to infix expression. I hope the logic is pretty simple and easy to understand. For any queries contact me at keepintouchsk@gmail.com
// Author: Skay
// Date: Nov 7, 2010
import java.util.Stack;
import java.util.Enumeration;
public class PrefixToInfixConverter
{
public static Stack<String> infixStk = new Stack<String>();
public PrefixToInfixConverter() { }
public static boolean isOper(String tstr)
{
if( tstr.equals("+") tstr.equals("-") tstr.equals("*") tstr.equals("/") )
return true;
else
return false;
}
public static String convert(String prefixStr)
{
String infixStr=new String();
String tempString = new StringBuffer(prefixStr).reverse().toString();
for(int i=tempString.length()-1;i>=0;i--)
{
while(tempString.charAt(i)==' ')
i--;
infixStk.push(String.valueOf(tempString.charAt(i)));
}
String[] val = new String[50];
int i,j;
while(infixStk.size()>1)
{
i=0;
while(!isOper(val[i++]=infixStk.pop()));
val[i-3] = new String("(" + val[i-2] + val[i-1] + val[i-3] + ")" );
for(j=i-3;j>=0;j--)
infixStk.push(val[j]);
}
return infixStk.pop();
}
}
Input: /-ab*c+de Output: ((a-b)/(c*(d+e)))
How does multithreading improve the performance of java program?
When you have only one processor and run a java program that does everything in memory eg., loops , calculations without looking up external datasources like Database, Socket, MQ , Web Service there wont be any performance benefit out of multithreading.
But when you have multiple processors on the host and you are doing to a large algorithm completely in memory it will definitely help to split your process into threads so different threads can be handled by different processorts
Event if you have on processor and if your java class (or program) does in memory calculations, algorithms + some external lookup like JDBC calls multithreading can greatly help the performance of your process. Your CPU would be free to do other tasks when your code waits for the database to return results.
I think you mean operation overlord??? It is the American, Canadian and British offensive on Europe in World War 2. They landed in Normandy on 6th June 1944 (Commonly called D-Day, Day of Days or Deliverance Day) and progressed throughout France liberating Paris on the 25th August. This allowed the allies a foothold in Europe.
In Java, a literal is the source code representation of a fixed value and are represented without requiring computation. The various types are Integer, Floating-Point, Character and String literals.
Where string is stored on Heap or Stack in java?
A String is treated as an object, meaning there is an object on the heap. Of course, the variable you define is a pointer to the object, and it is stored on the stack.
A String is treated as an object, meaning there is an object on the heap. Of course, the variable you define is a pointer to the object, and it is stored on the stack.
A String is treated as an object, meaning there is an object on the heap. Of course, the variable you define is a pointer to the object, and it is stored on the stack.
A String is treated as an object, meaning there is an object on the heap. Of course, the variable you define is a pointer to the object, and it is stored on the stack.
Program to concatenate the two strings without using build in functions?
#include<iostream>
#include<string>
int main()
{
using std::string;
string a = "hand";
string b = "bag";
string c = a + b; // concatenation
}
What is the disadvantage of circular queue?
A linear queue is a FIFO structure (first in, first out) akin to a queue of people waiting in line to be served on a first-come, first-served basis. There are no disadvantages provided you use it for the purpose intended.
You probably meant to ask what are the disadvantages of implementing a queue using a linear list. A linear list is a LIFO structure (last in, first out), which is akin to a stack of plates. The last plate on the stack is the first to be removed from the stack. In order to transform a linear list into a queue we must modify the behaviour slightly.
A linear list is typically implemented using a forward list (a singly-linked list) where every node points to the next node. Insertions and extractions always occur at the head node since the head node is the only node maintained by the list, and is therefore the only node with constant-time access. To locate the tail node, we must recursively traverse from the head node through each node's next node, until there is no next node. This traversal has linear complexity; the time taken to locate the tail node is directly proportionate to the number of nodes. Thus for a list of n nodes, it will take O(n) time to locate the tail node, but O(1) time to locate the head node.
To turn a linear list into a queue we must maintain a secondary pointer to the tail node. Extractions will still occur at the head but now insertions will occur at the tail. While this resolves the immediate problem, we're now using additional memory simply to maintain the tail pointer. Although the additional memory is minimal, there is a better way. If we point the tail node at the head node we create a circular list. This then means we can access both the head and tail nodes in constant-time through the tail node alone. Thus we no longer need to maintain a pointer to the head node.
To summarise, linear lists are disadvantageous when implementing queues because of the need to maintain two node pointers to achieve constant-time access to the head and tail nodes. Circular lists resolve the problem by utilising just one pointer to the tail.
Why do you think you would be exceptional for this position?
My strengths that I can bring to the company are pretty clear. I love finance and accounting, corporate governance and corporate finance. I like to get an in-depth understanding of business and finance, I am good at it, I like to work hard and get results.
Don't say anything about money.... That's why everyone needs a job or else you wouldn't be looking for one. Just tell them that you would love the experience and hope to do whatever your job is for the rest of your life. Or you can give them a resume.
How do you compiling a source code in java?
The javac command is used to invoke Java's compiler and compile a Java source file.
A typical invocation of the javac command would look like below:
javac [options] [source files]
Both the [options] and the [source files] are optional parts of the command, and both allow multiple entries. The following are both legal javac commands:
javac -help
javac ClassName.java OneMoreClassName.java
The first invocation doesn't compile any files, but prints a summary of valid options. The second invocation passes the compiler two .java files to compile (ClassName.java and OneMoreClassName.java). Whenever you specify multiple options and/or files they should be separated by spaces.
This command would create the .class files that would be require to run the java progam.
Write a java program to check a number is Armstrong number?
import java.io.*;
public class Jerry
{
public static void main(String as[]) throws IOException
{
int k=Integer.parseInt(as[0]);
int n=k;
int d=0,s=0;
while(n>0)
{
d=n%10;
s=s+(d*d*d);
n=n/10;
}
if(k==s)
System.out.println("Armstrong number");
else
System.out.println("not Armstrong number");
}
}
What is a variable in the Java?
A variable is something that can store data, such as numbers and words. One of the common types of variables is called "int", which can store numbers.
Creating a variable is simple:
int myVar;
"int" is the data type of the variable, and "myVar" is the name of the variable, you can choose almost any name you want for your variables.
Then you can assign a number to this variable, you can even use negative numbers:
myVar = 5;
Notice how you do not need to type "int" again, you only need to do it once when you create the variable.
Here's how to add numbers to variables:
myVar = myVar + 4;
OR
myVar += 4;
When you do either of these it will add 4 to the value of myVar, which means myVar now equals 9. (5 + 4 = 9)
You can also use subtraction: -
Multiplication: *
Division: /
and Modulus: %
Another imortant data type is the String, a String can store words and letters, and behaves much like an int.
String myVar;
myVar = "Hello";
myVar += " there, Sir.";
Now, like we did with the int earlier, myVar equals "Hello there, Sir."
One last thing, you can add different variables together, but they must be the same data type:
myVar += anotherVar;
When you delete a file from your computer the file is not really deleted, it is merely left there & the space it occupies is made available to be written over.
'Oops' is a program that allows you to call up deleted files & by restoring the name of the file to the original name (by the addition of the first character of the original name) rewrites them to disc.
e.g. Original file name was backup.exe. when file is deleted it becomes _ackup.exe
when using 'oops' you simply put the 'b' on to the deleted & it is restored. Object Oriented Programming System
An abstract class is a class that cannot be directly instantiated. The purpose of such a class is to put some logic in a base class and force derived classes to implement the remaining functionality. Since the full functionality is only available in the derived class, the base class is declared as abstract so that it cannot be instantiated directly.
Difference between connectionless and connection oriented communication?
Different from a connectionless protocol, a connection-oriented protocol guaranties the delivery of the information. An example of connection-oriented protocol is (TCP) and a connectionless protocol is (UDP). page/926 A+
Why use catch keyword in java?
no, because catch is used to handle exceptions which are generated from try block
How do you access nembers of a class?
Use the class member access operators. For object references, use the . operator, for pointers, use the -> operator.
class obj
{
public:
void foo(){}
};
void main()
{
obj o, *p=&o;
o.foo(); // Access member via reference.
p->foo(); // Access member via pointer.
return( 0 );
}
import java.io.*;
public class sum{
public static void main(String[] args) {
try{
System.out.print("Enter 10 numbers: ");
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int[] input=new int[10];
int a,total=0;
for(a=0;a<10;a++) {
System.out.println();
input[a]=Integer.parseInt(br.readLine());
}
for(a=0;a<10;a++) {
total+=input[a];
}
System.out.println("The sum of the numbers is "+total);
}catch(Exception e) {
e.printStackTrace();
}
}
}
What is the similarity between 'if' statement ans 'switch' statement?
A Switch statement can be considered as a series of if. else if. else statements. whatever condition is satisfied, the code block would get executed.
if (cond 1) {
} else if (cond 2) {
} else if (cond 3) {
} ......
} else if (cond N) {
} else {
}
switch {
case 1: ....
case 2: ....
....
case N: ...
default: ...
}
Difference:
In the if else blocks, if one condition is satisfied, all other blocks are ignored
In Switch blocks, unless you have break statements inside each condition block, the subsequent blocks would not be ignored.
What is primitive and non primitive cell?
Primitive unit cells use every lattice point as a unit cell vertex.
Non-primitive unit cells, however, contain extra lattice points not at the corners.
What is the difference between j2sdk and jdk?
JDK is java development kit whereas J2SDK is the newer one and is called as Java 2 software development kit.