How do you print 1 121 1331 14641 in c?
#include
#include
void main()
{
clrscr();
for (int i=1;i<=5;i++) // this for loop controls the line
{
for(int
j=1;j<=i;j++) // this for loop controls the values(1,12,123..)
{
printf("%d",j);
}
printf("\n");
}
getch();
}
What are differences between user defined packages and predefined packages in java?
As we know, default package of java.lang.*; is implicitly called if it is not explicitly called Ok, So. Package is Collection Classes ( abstract or interfaces).
Package Creation :-
1 ) First line of the program, in which you want create a package must be a your desired package name starting with package keyword and followed by semicolon.
2 ) While creating package, it is not necessary to write public before each class name.
3 ) But, each and ever method must be public.
Creating or Compiling Package :-
Syntax :-
D:\Practice\Javac -d < Path of program >
Complete Example :-
package TYBCS;
class Mathematics
{
public int addNumbers(int num1,int num2)
{
return(num1+num2);
}
public static double addFloatNum(double num1,double num2,double num3)
{
return(num1+num2+num3);
}
}
class Maximum
{
public int getMaxOutofThree(int n1,int n2,int n3)
{
int num=0;
if(n1>n2 && n1>n3) { num=n1; }
if(n2>n1 && n2>n3) { num=n2; }
if(n3>n1 && n3>n2) { num=n3; }
return num;
}
}
class Practice
{
public static void main(String args[])
{
Mathematics m=new Mathematics();
Maximum mx=new Maximum();
System.out.println("Addition 5+5 : "+m.addNumbers(5,5));
System.out.println("Addition f 2.5+2.5 : "+m.addFloatNum(2.5,2.5,2.5));
System.out.println("Max Number 7, 8 , 1 : "+mx.getMaxOutofThree(7,8,1));
}
}
/*
Output:-
D:\Data>javac -d D:\Data\ Practice.java
D:\Data>java TYBCS.Practice
Addition 5+5 : 10
Addition 2.5+2.5 : 7.5
Max Number 7, 8 , 1 : 8
D:\Data>
*/
What is interface in a compouter?
In Java , Graphical User Interface (GUI) programming. Users interact with modern application programs using graphical components such as windows, buttons, text boxes, and menus. It would be difficult to write a GUI application from scratch. Luckily, most of the work has been done for you in a set of classes called Swing.
There a program that uses both interpreted and compiled code?
Yes.EasyTreve Plus has both an interpreted and a compiled version available.
In homeopathic medicine, apis is used as a remedy for many symptoms similar to those of bee stings.
Example a program using two dimensional array multiplication table?
#include <stdio.h>
int main() {
int TimesTable[12][12] = { {1,2,3,4,5,6,7,8,9,10,11,12}, {1,2,3,4,5,6,7,8,9,10,11,12} };
int a, b;
for (a = 1; a <= 12; ++a) {
for (b = 1; b <= 12; ++b) {
TimesTable[a][b] = a*b;
printf("%5d", a*b);
}
printf("\n\n");
}
return 0;
}
How is object oriented programming language easier to use than procerdural programming language?
object oriented programing helps better modeling the world as we humans see it, while functional and procedural programming is for the mathematicians P.O.V. harder to maintain the code, and for me , harder to understand imperative(functional) code over side effect code(OOP) OOP is more intuitive by the grasp of the model to the mind, as it stands to help better model the mind, though most developers i have see so far, can really make a good simulation for the world in order for the code to be more coherent. OOP is Object Oriented Programming P.O.V is Point Of View
What is production testing in Software development?
Production is when software is installed on the client's hardware and is being used for real.
Production testing is when you are testing a real live system, either about to go live or with live users. It is needed because having software working on the developer's computer is no guarantee that it will work in the client's installation.
As an example, if you are developing a website for a client, you will probably test the code on the machine you are developing on. If there are several developers, you may also have a test server where you merge the contributions from different people and check that they work together.
In addition to that, you will have to test when the site is installed on the servers where it is going live. This last one is production testing.
Which is java default access specifier?
There is no such thing as an access specifier in Java. There are access modifiers.
The default access modifier if unspecified is to allow access to classes in the current package only, except within an interface where the default is 'public'
Who is the best java programmer?
How much a base class members can access of derived class?
Ideally, none. Base classes should have no knowledge whatsoever of their derived classes and therefore should have no access to any members declared in the derived classes. However, derived class methods are accessible via virtual functions declared in the base class. The correct methods (overrides) are called via the virtual table, but the base class itself requires no specific knowledge of the derived class in order to call these methods. This makes sense since a base class cannot know in advance all the classes that may or may not derive from it in the future.
If a method must be guaranteed to be implemented by a derived class, a pure-virtual method can be declared in the base class instead. This renders the base class abstract, meaning you cannot instantiate an object from the base class, only from a derivative that fully implements (or inherits) all the pure-virtual methods.
Conversely, a derived class can access all the public and protected members of its base class.
What is an abstract factory pattern?
An abstract factory pattern is a creational design pattern which decouples the object creation by providing a group of individual factories by defining an abstract factory class.
Is the for loop a pretest type of loop?
Pretest loops, such as for-loop, while-loop, execute/evaluate the condition statement first, if the condition is met, then the statements of the loop are executed. If you were referring to the body of the loop being carried out at least once, no, the body will not be touched if the condition fails (pre-test, test BEFORE the [next] execution of the body). But the condition of the loop must have been evaluated at least once.
In contrast to the post-test loops, such as do-while, repeat-until, the condition is evaluated AFTER the [next] execution of the body. It is possible that the condition is never evaluate, and not the entire loop body being executed.
Write a program in java to print a statement in reverse order?
/* Input: Do Your Duty
* Output: Duty Your Do
*/
import java.io.*;
class RevSent
{
protected static void main()throws IOException
{
BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter the Sentence: ");
String s=in.readLine();
char ch; short a=0,b=0;
for(short i=0;i<s.length();i++)
{
ch=s.charAt(i);
if(ch==' ')
a++;
}
String w[]=new String[a+1];
for(short i=0;i<=a;i++)
w[i]="";
for(short i=0;i<s.length();i++)
{
ch=s.charAt(i);
if(ch==' ')
b++;
else
w[b]+=ch;
}
for(short i=a;i>=0;i--)
System.out.print(w[i]+" ");
}}
Which one is better between Compiler and interpreter?
A compiler is a program that takes a programming language like that of java and then translates it into computer language for the software user. The interpreter just ( just like that of a human interpreter) takes the foreign language which would be that of the programming language and turns it into the machine code. Both of these programs take a high-level programming language and translates them into the machine code, but the interpreter is slower to translate than the compiler because of the fact it processes and interprets each statement many times.
Full form of OLEDB is Object Linking and Embedding database.
Why do cathedrals need gargoyles other than for protection?
gargoyles also serve as rain spouts, there is a dish with a hole in the gargoyle that collects rain and lets it out of the gargoyle's mouth. gargoyle serve as raiinspouts as well
java was discovered by James gosling and Co. in 1991 at sun micro systems..they renamed oak to java..initially java used in programming for set top boxes (for movie on demand..)
How can a value from the derived class be assigned to a variable in base class?
Remember that derived classes can access the public and protected members of their base class, but none of the private members. If the member variable in the base class is protected (rather than private), then the derived class can assign it directly. However, this is bad style in OOP as it undermines data-hiding. A protected mutator (set accessor) would be a better option.
Java program to give input of a string and display it?
import java.util.*;
public class Example
{
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
System.out.println("Please enter a string:");
String input = in.next();
System.out.println("The String you entered is: " + input);
}
}
Difference between public member and private member of a class in Java?
public members can be accessed from outside the class they were declared in, private members can only be accessed from within the class they were declared in. Private members are commonly manipulated through get/set methods, which allows for greater encapsulation and hides the implementation from the calling function.
Example:
class sampleClass{
private: int private_member;
public: int public_member;
public: void setPrivateMember(int x){private_member = x;}; // private members can be accessed from within the class that they are declared in
public: int getPrivateMember(){return private_member;};
};
int main()
{
sampleClass A;
A.public_member = 5; // Perfectly legal
A.private_member = 7; // Syntax error, this will not compile
A.setPrivateMember(7); // Legal
cout << A.getPrivateMember(); // Legal
return 0;
}
What does System.out.println mean in java?
System : is predefined class.
out : is a Output Stream which connects to console.
print : is to print in console.
println: used to print with next line