We can use any method. As we can find out the area of the circle by three methods as i known.
1.ordinary programming
e.g. void main() {
int r;float area;
printf("\n\tEnter radius of the circle : "); scanf("%d",&r); area=3.14*r*r; printf("Radius = %d and area=%f",r,area); } 2. By using macros e.g. #define PI 3.14
#define AREA(x) PI*x*x 3. We can solve by user defined functions also
Do you use an array when you only have two or three items to track?
Yes. Using an array when multiple elements need to be created at a time is always a better idea than declaring multiple variables. For ex:
Int i, j, k;
Int[] arr;
I have declared 3 int variables and another array just below it. Here since we are using only 3 variables, we can manage to use them without issues but if the number crosses 5 or even more then definitely using an array is always the best option.
What are the constructors are used to create an object of the file class?
There are three constructors that can be used to create a File class.
To create a new File object:
File newFile = new File("something");
How do you learn struts frame work?
To learn struts your self, you can get best documentation from Apache site
URL: http:/struts.apache.org
Struts 1 and Struts 2 are totally different API. Struts 1 is very famous. Right now lot of development community and teams are building applications using Struts 1.3. I feel it is better to learn Struts 1 in depth. and you can learn yourself struts 2 when it becomes popular.
For live examples, practice and quick learning better to take classes.
----
I know that Strategic Agile Technologies provides on-line java training. The trainings are really good. To learn Struts in depth you can take on-line course from them.
URL: http:/strategicagile.com/JavaTraining.aspx
This is not a question, it is an assignment.
class Geo {
public:
virtual double area (void) const = 0;
virtual ~Geo (void) {}
// ...
};
class Rect : public Geo {
private:
double m_width;
double m_height;
public:
Rect (double width, double height): m_width (width), m_height (height) {}
double area (void) const override { return m_width * m_height; }
~Rect (void) override {};
// ...
};
class Sqr : public Rect {
public:
Sqr (double width): Rect {width, width} {}
~Sqr (void) override {}
// ...
};
Writ evolution program ofInfix convert postfix without using classes or structures?
//made by vijay sahu
#include
#include
void main()
{
char p[20];
int stack[15];
int ts=-1,top=0;
int l=strlen(p);
cout<<" \n enter postfix expression";
cin>>p;
for(int i=0;i
{
if(p[i]>=48 && p[i]<=57)
stack[++ts]=p[i]-48;
else if(p[i]=='+' p[i]=='-' p[i]=='*' p[i]=='/')
{
int t1=stack[ts--];
int t2=stack[ts--];
switch(p[i])
{
case '+':
stack[++ts]=t1+t2;
break;
case '-':
stack[++ts]=t2-t1;
break;
case'*':
stack[++ts]=t1*t2;
break;
case '/':
stack[++ts]=t2/t1;
break;
}
}
}
cout<
}
How many types can write public static void main in java?
You can write it in as many ways as you want. The words public, static and void can be interchanged during the method declaration and still the main() method will continue to work in the same way.
i.e., public static void main(String[] args) is the same as static public void main(String[] args)
However, if you miss either of these 3 keywords from the method signature, the compiler will still let you compile the method, but it just won't be the main method that can be used to start the program execution.
What is a canonical view for object oriented analysis and design?
canonical view
Common parlance loosely defines canonical views as the "front", "side", and "top" views of an object.
http://www.bmva.ac.uk/bmvc/2005/papers/264/paper.pdf
The term "canonical views" was first used by Palmer, Rosch, and Chase (1981). For more information on their experiements see:
http://www.kyb.tuebingen.mpg.de/publications/pdfs/pdf1507.pdf (its worth reading the section about the experiments to get a fuller understanding of their meaning) Given these facts, my best guess is that "canonical view" in the context of OOAD is what the application "looks like" from various points of view... UI, application layers and so on.
Is it ever necessary to add extends Object to a class declaration?
No; that is the default. In other words, if you don't add "extends", the class will automatically inherit from the "Object" class.
No; that is the default. In other words, if you don't add "extends", the class will automatically inherit from the "Object" class.
No; that is the default. In other words, if you don't add "extends", the class will automatically inherit from the "Object" class.
No; that is the default. In other words, if you don't add "extends", the class will automatically inherit from the "Object" class.
class is a blueprint which does not have its own existence but it can pass all of its feature to its child classes.
Does exception always signal an error?
It depends on exactly how you define an error. If an exception is thrown, then it means something has gone wrong.
Some Exceptions, such as a NullPointerException, will almost certainly signal an error in your code or data. Others, such as IOExceptions, can be caused by things outside your control, and would probably not be considered errors.
Does the pseudo random noise and the pseudo random signal the same?
both are same as both will repeat after some period distinguishing it from random noise/signal which will never repeat
What Difference between exception and assertion?
Exception means not included in general sense. Any subject an ve connotaion in general with few exeption. Assertion means asserting one's authority
Virtual inheritance is used in multiple inheritance hierarchies whenever two or more classes inherit from the same base class. For example, consider the following minimal example:
struct A {int x;};
struct B : A {};
struct C : A {};
struct D : B, C {};
Here, A is a common base class of both B and C, thus B::A and C::A are independent instances of A. However, D inherits from both B and C thus indirectly inherits both B::A and C::A. This introduces an ambiguity when implicitly referring to A from D, as in the following example:
D d; d.x = 42; // error: ambiguous
When the compiler sees this it won't know whether we are referring to B::A.x or C::A.x, thus we must be explicit when referring to A via D:
d.B::x = 42; // ok
The problem with this is that we still have two separate instances of x so unless we are extremely careful about which x we are referring to we can easily end up with two different values for x with no way of knowing which was the correct value with respect to D.
What we really need is for B and C to share the same instance of A and we achieve that through virtual inheritance:
struct A {int x;};
struct B : virtual A {};
struct C : virtual A {};
struct D : B, C {};
D d;
d.x = 42; // ok
Note that d.x can be referred to as d::A.x, d::B::A.x or d::C::A.x because they all refer to the same instance of x, thus the ambiguity is eliminated. In effect, the most-derived class in the hierarchy (D) is now a direct descendant of A rather than an indirect descendant of both B::A and C::A.
Note also that the virtual keyword has no effect on independent instances of either B or C because they then become the most-derived classes within their own hierarchy and therefore behave exactly as they would had the virtual keyword been omitted. The virtual keyword only comes into play when we derive from a class with a virtual base.
It is also possible to have a base class that is both virtual and non-virtual in the same hierarchy:
struct A {int x;};
struct B : virtual A {};
struct C : virtual A {};
struct D: A {}
struct E : B, C, D {};
Here, A is a virtual base of both B and C, as before, but not of D. Thus E::A implicitly refers to the virtual A while E::D::A must be explicitly referred to as E::D::A because it is a separate instance. Such classes are best avoided, but if we don't have access to the source code we sometimes don't have a choice in the matter.
However, if a base class holds no data it really doesn't matter whether it is declared virtual or not because a class that has no data consumes just one byte regardless of how many instances there are.
Write a algorithm to print even number in C programming language?
#include<stdio.h>
#include<conio.h>
void main()
{
int n;
clrscr();
printf("\n enter the number:");
scanf("%d",&n);
if(n%2==0)
printf("\n the number is even");
getch();
}
Describe the JAVA throwable class hierarchy and types of exceptions?
In Java there are two main types of Exceptions.
* Checked Exceptions - The ones that can be checked & handled in our code. Ex: I/O Exception, SQL Exception etc. In most cases, the compiler itself forces us to catch & handle these exceptions
* Un-checked Exceptions - The ones that we cannot & should not handle in our code. Ex. Null Pointer Exception
The java.lang.Throwable is the super class of all errors and exceptions in Java. Only objects of this class can be thrown & caught and handled by try-catch blocks.
Ex:
try {
.....
.....
} catch (Exception e){
...
} finally {
...
}
How to link to external url in javadoc?
Here's an example:
@see <a href="http://www.google.com">Google</a>
How can you search an array element in a file?
Logic to search element in array
Input size and elements in array from user. ...
Input number to search from user in some variable say toSearch .
Define a flag variable as found = 0 . ...
Run loop from 0 to size . ...
Inside loop check if current array element is equal to searched number or not.
To learn more about data science please visit- Learnbay.co
Explain the usage of JPanel with example?
JPanel, a part of Java Swing package, is a container that can store a group of components. The main task of JPanel is to organize components, various layouts can be set in JPanel which provide better organization of components, and however it does not have a title bar.
For Example:
Program to create a JPanel with a Border layout and add components to it .
// java Program to create a JPanel with a Border layout and add components to it . import java.awt.event.; import java.awt.; import javax.swing.*; class solution extends JFrame { // JFrame static JFrame f; // JButton static JButton b, b1, b2, b3; // label to diaplay text static JLabel l; // main class public static void main(String[] args) { // create a new frame to stor text field and button f = new JFrame("panel"); // create a label to display text l = new JLabel("panel label"); // create a new buttons b = new JButton("button1"); b1 = new JButton("button2"); b2 = new JButton("button3"); b3 = new JButton("button4"); // create a panel to add buttons and a specific layout JPanel p = new JPanel(new BorderLayout()); // add buttons and textfield to panel p.add(b, BorderLayout.NORTH); p.add(b1, BorderLayout.SOUTH); p.add(b2, BorderLayout.EAST); p.add(b3, BorderLayout.WEST); p.add(l, BorderLayout.CENTER); // setbackground of panel p.setBackground(Color.red); // add panel to frame f.add(p); // set the size of frame f.setSize(300, 300); f.show(); } }
Static Variables are created when the class is loaded and continue to exist as long as the class is loaded/present in the JVM