Can abstract class have constructors?
A constructor of a class in invoked when a object of that class is created. As an abstract class can't have an object, so we can't create a constructor of the abstract class. But we can create a constructor of a concrete subclass of that abstract class and we have to pass the object of that concrete subclass to the abstract class.
Which is better vector or array list?
It depends...
If you want a speedy processing go for array list
If you want thread safety go for a vector
Program for derived class in cpp?
#include<iostream>
class base
{
int m_data;
public:
base(const int data):m_data(data){}
base(const base& cpy):m_data(cpy.m_data){}
base& operator=(const int rhs){m_data=rhs;return(*this);}
base& operator=(const base& rhs){m_data=rhs.m_data;return(*this);}
virtual ~base(){}
};
class derived
{
public:
derived(const int data):base(data){}
derived(const derived& cpy):base(cpy){}
derived& operator=(const int rhs){return(base::operator=(rhs));}
derived& operator=(const derived& rhs){return(base::operator=(rhs));}
virtual ~derived(){}
};
int main()
{
derived d=42;
}
Can element of character arrays be accessed in the same way as the elements of a numeric arrays?
Yes, it can.
Why is an event considered world level in Alice?
When a class level object is added it responds to the world
The methods cannot have the same name in java true or false?
False. Methods in a class can have the same name as long as they have a different signature. You cannot duplicate method code inside a class but you can always have methods that have the same name but a different signature.
Ex: Here I have created two methods in a class that have the same name "sum" but have a different argument types, and return types and hence perfectly allowable in a java class.
Public class PolymorphismExample {
public int sum(int a, int b){
return a + b;
}
public double sum (double a, double b){
return a + b;
}
}
Why is the top level class is considered the largest class in a class hierarchy?
I wouldn't consider it any larger than other classes - it is just the top of the hierarchy.
How do you communicate between object and object in java?
Communication between object
In java , objects communicate by message passing.
An object oriented program is nothing but a bunch of objects telling each other what to do". To pass a message to an object means that a call to a method of that object is placed.
An object by itself is not incredibly useful. In general, it takes more than one object to really do anything meaningful. Since multiple objects typically need to communicate with each other, it stands to reason that an OOP language such as Java must provide some kind of object communication mechanism.
Object: An object is a collection of data and the procedures (methods) that act on that data.
Java Messages:
Java objects use messages to communicate with each other. Messages simply tell an object what to do. In Java, the act of sending a message to an object involves calling one of the object's methods .
It is a common practice to pass additional information along with a message. This information is passed along with the message as message parameters. More specifically, the message information is passed into a method as method parameters.
Message passingis another way of saying "method calling." When an object sends a message to another object, it is really just calling a method on that object. The message parameters are really just the parameters to the method. The bottom line is that messages and methods are synonymous.
Multilevel DD (Difference-in-Differences) is an econometric technique used to analyze causal relationships in data with hierarchical structures, such as individuals nested within groups or regions. It extends the traditional Difference-in-Differences approach by allowing for variations at multiple levels, enabling researchers to account for both individual-level and group-level factors. This method is particularly useful in evaluating policy effects over time while controlling for unobserved heterogeneity across different levels of analysis. It helps provide more robust estimates of treatment effects in complex datasets.
What is the programming language used for e-banking?
VB.NET is used for e-banking.It is the language in which all the options are used just by tool box that is at the right hand side of the window.
This question is like asking "what brand of wrench is used to make cars?". There are thousands of different e-banking sites and connections, and they use practically all languages ever designed to run at least one of those possible e-banking places.
The bubble sort algorithm can be applied to an array of characters. Every character can be translated to an integer equivalent via the ascii table
What is meant by 'else without if '?
I'm guessing that this showed up as part of a compilation error. What it means is that it found an "else" statement without an "if" statement preceding it.
{
// this is the normal form of an if-else block
if(a==b) {
;
}else {
;
}
// this causes an "else without if" error
else {
;
}
}
Take an array of 5 numbers and find smallest and largest elements?
There are many ways to do this. One way is to import "java.util.Arrays;." Then you can make your array of numbers. For example int[] test = {4, 123, 432, 314}; Then later on in the code you can use Arrays.sort(test); That will sort it from min to max. Then to output it. System.out.println(test[0] + " " + test[length-1]);
What is the difference between a persistent object and a transient object?
a persitent object is the one that is stored permanently on the disk......whereas a transient object is stored temporarily on the ram....
How do infix notation and postfix notation differ?
It's simply a matter of where the operators are placed in relation to their operands:
infix: X + Y
prefix: + X Y
postfix: X Y +
All of the above are equivalent.
Prefix notation is also known as Polish notation, hence postfix is also known as reverse Polish notation.
Given the infix equation A * B + C / D, the order of evaluation is always parenthesis, orders, divide/multiply, add/subtract (PODMAS), thus we must multiply A by B first, then divide C by D, and finally add the two results together. If we wish to perform the addition first, then we must re-write the equation with parenthesis: A * (B + C) / D.
With postfix and prefix notation, operator precedence becomes superfluous because we always evaluate these expressions in left-to-right order:
Infix A * B + C / D becomes postfix A B * C D / + or prefix / * A + B C D
Infix A * (B + C) / D becomes postfix A B C + * D / or prefix + * A B / C D
When we eliminate operator precedence with postfix or prefix notation, we greatly simplify the algorithm required to evaluate complex expressions. For example, given the postfix expression A B C + * D /, we simply read the symbols one at a time, placing them on a stack, until we encounter an operator. We then pop the first two elements off the stack, perform the operation, and then pop the result back on the stack. We repeat this process until there are no more symbols left, at which point the stack holds just one value: the result.
With prefix notation, we place the operators on the stack instead of the operands. When we read the first operand we simply store it in an accumulator. We continue pushing operators onto the stack until we encounter the second operand, at which point we can pop the first operator off the stack, perform the operation and update the accumulator. We repeat this process until there are no symbols left, at which point the accumulator holds the final result.
Note that when presented with an infix expression, a machine has to convert the expression to the equivalent prefix or postfix expression before it can be evaluated. By eliminating this conversion process, computation by machine can be performed with much greater speed.
A thread safe object is one that would be safe even if multiple thread instances are accessing it. For example if a single object is being updated by a thread and the same object is being read by another thread - we will end up with an inconsistency where the reading object is reading incorrect data because by the time it finishes reading, another thread would've updated it. So we use the keyword synchronized with methods to ensure that such a situation does not happen.
An object that wont let two threads access it simultaneously is called a thread safe object
What is a java virtual machine?
An abstract computing machine, or virtual machine, JVM is a platform-independent programming language that converts Java bytecode into machine language and executes it. Most programming languages compile source code directly into machine code that is designed to run on a specific microprocessor architecture or operating system, such as Windows or UNIX. A JVM -- a machine within a machine -- mimics a real Java processor, enabling Java bytecode to be executed as actions or operating system calls on any processor regardless of the operating system. For example, establishing a socket connection from a workstation to a remote machine involves an operating system call. Since different operating systems handle sockets in different ways, the JVM translates the programming code so that the two machines that may be on different platforms are able to connect.