Answer:
The class is called MyApp which inherits from JFrame and implements the ActionListener interface.
Explanation:
The class is called MyApp which extends the swing class JFrame and implements the ActionListener interface for event handling. As a results it needs to implement a method called actionPerformed for handling the relevant events that may be raised from the user interface. Since it extends JFrame, it has access to all the public and protected methods defined in JFrame(for example setTitle to set the title of the frame).
The Java class definition 'public class MyApp extends JFrame implements ActionListener' shows that MyApp is a public class extending JFrame and implementing ActionListener. This means it inherits from JFrame and must provide the actionPerformed method. An example demonstrates adding a button to the JFrame and handling button clicks.
The given Java class definition public class MyApp extends JFrame implements ActionListener indicates several important things:
public class: The class MyApp is public, meaning it can be accessed from other classes.extends JFrame: The class MyApp is a subclass of JFrame, which means it inherits properties and methods from the JFrame class. JFrame is part of the Java Swing library used for creating graphical user interfaces.implements ActionListener: The class MyApp implements the ActionListener interface. This means MyApp must provide an implementation for the actionPerformed method defined in the ActionListener interface. This method is typically used to handle events, such as button clicks.Here’s a simple example to illustrate:
import javax.swing.*;In this example, a button is added to the JFrame, and when clicked, the actionPerformed method is triggered, printing a message to the console.
As of MySQL 5.5, which of the following is the default table storage engine?
(a) Blackhole
(b) SuperNova
(c) Memory
(d) MyISAM
(e) InnoDB
Answer:(d) MyISAM
e) InnoDB
Explanation: MyISAM is type of default engine storage in table form in MySQL 5.5.It is discontinued and no longer available service.It had the feature of creating a backup, able to create replicas,data dictionary automatic updates etc in table.
InnoDB took over on the place of MyISAM in MySQL 5.5 as the default engine storage when MyISAM was discarded. It has the capability to support foreign keys, tablespaces, operation of spatial nature etc.
Other options are incorrect because black-hole is mechanism of data packet destruction without the acknowledgement of sender, supernova is type of computer unit and memory is the operating unit part where the data storage takes place.Thus the correct options are (d) and (e).
We all know everything there is to know about the Fibonacci sequence, right?
Answer:
Yes.
Explanation:
Fibonacci Sequence is the series of numbers which are the sum of previous two number in the series.Two numbers are predefined in the Fibonacci sequence.The first number in the series is always 0 and the second number in the series is always 1.
We need atleast two numbers to start fibonacci sequence so that the series can be generated.
. Which of the following is the command for backing up a database from the command line?
(a) mysqlslap
(b) mysqlshow
(c) mysql --backup
(d) mysqldump
Answer:d) mysqldump
Explanation: The backing up of the database is the function that is operated by the MYSQL. The database that is to be backed up is known as the dump data ,which contains the data files in the text format."mysqldump" command is the SQL command that is given for the extraction of the single database as well as multiple databases.
This command works by recreating the data files by copying it in a quick manner.Other options are incorrect because those commands don not work in MYSQL for creating a backup of database.Thus, the correct option is option(d).
Why do small incremental code changes in software have to do with testing?
Answer:
It is method where the product is designed, implemented and tested incrementally until the product is finished.
Explanation:
Small incremental codes are used to find the errors or bugs in the program coding or in the development of software. The whole process of incremental codes in software testing is categorized in smaller chunks, and the process is executed in steps of design, requirement, and implementation. If an error occurs in each step of the testing phase, it will be detected. This process is economical and easy to use due to smaller chunks.
Write a program that continues to read positive integer values until user enters a negative value. The program should print average of entered values, maximum value and minimum value
Answer:
// here is code in C++.
#include <bits/stdc++.h>
using namespace std;
int main()
{
// variable
int n;
int mi=INT_MAX;
int mx=INT_MIN;
double avg;
int count=0;
double sum=0;
cout<<"enter a positive integer(Negative number to stop):";
// read the input first time
cin>>n;
// read the input until user enter a negative number
while(n>=0)
{
// calculate minimum
if(n<mi)
mi=n;
// calculate maximum
if(n>mx)
mx=n;
// count of entered numbers
count++;
// total sum of all number
sum=sum+n;
cout<<"enter a positive integer(Negative number to stop):";
// read the input again
cin>>n;
}
// calculate the average
avg=sum/count;
// print the average
cout<<"average of "<<count<<" number is:"<<avg<<endl;
// print the maximum
cout<<"maximum of all number is:"<<mx<<endl;
// print the minimum
cout<<"minimum of all number is:"<<mi<<endl;
return 0;
}
Explanation:
Declare and initialize "mi" with maximum integer value.Similarly "mx" with minimum integer value.Read user input until user enter a negative number.Add all the number to variable "sum" and keep count of positive number entered with "count".When user enter a negative number then it will stop taking input and calculate average of all number by dividing sum with count. Also it will check for each and find the maximum and minimum among the all input.
Output:
enter a positive integer(Negative number to stop):23
enter a positive integer(Negative number to stop):10
enter a positive integer(Negative number to stop):34
enter a positive integer(Negative number to stop):22
enter a positive integer(Negative number to stop):5
enter a positive integer(Negative number to stop):-2
average of 5 number is:18.8
maximum of all number is:34
minimum of all number is:5
Write a program with the following output: ( Notice the beeline and space). Hello world! Hello
Answer:
#include <iostream>
using namespace std;
int main() {
cout<<"Hello world! Hello";//statement to print the statement.
return 0;
}
Explanation:
The above written program is in C++.In C++ cout is used to print ouput on the screen and it is called standard output.So to print Hello world! Hello you have to code
cout << "Hello world! Hello";
This will print the statement.
Answer:
Hello!
Explanation:
Which command compiles the Java source code file Welcome.java?
cd Welcome.java
javac Welcome.java
java Welcome.java
compile Welcome.java
Answer:
javac Welcome.java
Explanation:
In order to the file to compile with the default compiler in the JDK, the instruction must be of the form:
javac filename
(Note: the filename with the .java extension)
What are some of the benefits of a single language for all programming domains? Give me 3 or 4 benefits (pros not the cons)
Answer:
All the individual programming language have their individual important which is specific according to the their own style of leaning the programming language and simplicity to learn. The syntax should be in proper format and follow legacy.
Some of the benefit of the single programming language for all the domain are as follows:
By using the single language, it basically reduce the complexity of the program. The compiler maintenance cost would be reduced and easy to maintain. It increases the efficiency of the code and also the compilation efficiency in the system.The network administrator is often involved in selecting and implementing network security measures such as firewalls and access codes.
True
False
Answer: True
Explanation:
Yes, the given statement is true that the network administrator are basically involve in the select and implement the various network security measures like the access code and firewall.
The network administrator is basically responsible for managing, implementing and troubleshooting the LAN areas that is local area network in the organization. The network administrator is the technology which is widely used now a days for efficient development. It is also interface with the internet and wide area networks (WAN).
The basic building block of a system is the _____. (Points : 6) object
attribute
message
partition
method
Answer: Object
Explanation: Object is a major part of a system that has the relevance with the real world entities.The objects are used in the object-oriented approach in the operating system for the development and maintenance of it.
It is the component that comprises of the two major factors-code and data. The code and data are for the determination of the behavior and the status of the object respectively. Other options are incorrect because they don't operate as the building block for a system.
What is a split form?
Answer:
The split form is the type of feature which are introduced by the Microsoft access in 2007. This feature basically give two view of the data at the similar time that is:
Datasheet view Form viewThese two views are basically connected with the same source of the data and they are basically synchronize with the each other. From the datasheet view we can easily select the field in the record. We can also modify the data by using the functions such as add,delete and edit.
Write a C++ program where Two or more strings are anagrams if they contain exactly the same letters, ignoring capitalization, punctuation, and spaces. For example, "Information superhighway" and "New utopia? Horrifying sham" are anagrams, as are "ab123ab" and "%%b b*aa". Note that two lines that contain no letters are anagrams.
Answer:
/*
Problem; to finf s2 strings are anagrams.
(s2 strings are anagrams if they contain exactly the same letters, ignoring capitalization, punctuation,)
and spaces.
Solution: we must take account wich letters are present in each string and how many times. To achieve that we
may create a struct with a char and a char count, some constructors, both geters and an equal operator.
*/
#include <iostream>
#include <vector>
using namespace std;
struct charCount {
private: // Internal data structure:
char letter; // letter (should be unique)
unsigned int letterCount; // and is present at least 1 time
public:
charCount() {} // Default Constructor
charCount(char l) {letter = l; letterCount = 1;} // Constructor
charCount(const charCount & other) {letter = other.letter;
letterCount = other.letterCount;} // Copy Constructor
void increments() {letterCount++;} // Counts other occurrence
char ltr() {return(letter);} // Geter
unsigned int ltrCount() {return(letterCount);} // Geter
bool operator ==(charCount other) {return(letter == other.letter // Equal means same char and
&& letterCount == other.letterCount);}// same count.
};
/*
We have to analyze each input string returning an ordered vector of charCount elements:
*/
vector<charCount> analysis(string s) { // Raw string data
vector<charCount> result; // Result vector
for(char c:s) { // For each char of string: we take a-z
if(isalpha(c)) { // only into account and we normalize it
char x = tolower(c); // to lowercase, store as x and we are
bool found = false; // ready to search
unsigned int pos = 0; // from first position to last
for(auto & y:result) { // for each vector's element
if(y.ltr() == x) { // if we find x, we must
y.increments(); // count this occurrence,
found = true; // turn on the found flag
break; // and exit from the loop.
} else if(y.ltr() < x) { // Otherwise may be we are not going to
result.emplace(result.begin()+(pos),(charCount(x))); // find it in the ordered vector: we insert
found = true; // it at current vector's position. It is
break; // present now: we should exit from loop.
} else pos++; // Otherwise we increment pos and go on.
}
if(!found) { // x doesn't belongs to vector's set: we
auto it = result.end(); // add it at last position, keeping order
result.insert(it,(charCount(x))); // and we may go on for another cycle if any.
}
}
}
return result;
}
template <typename T> // Generic code follows to implement
bool operator ==(vector<T> v1,vector<T> v2) { // 2 vectors comparison: they are
bool result = (v1.size() == v2.size()); // equals if their sizes match,
if(result) // and each element from first vector
for(unsigned int i = 0; i < v1.size();i++) // matches with each element from the
result = result && v1[i] == v2[i]; // second vector at the same position.
return(result);
}
template bool operator ==(vector<charCount>,vector<charCount>); // Orders compiler to generate a charCount version.
bool areAnagrams(string s1,string s2) { // Anagrams implies 2 identical analysis vectors.
return(analysis(s1) == analysis(s2));}
int main(int argc, char *argv[]) { // Test code folloes:
string s1,s2; // 2 strings to store input data.
cout << "Text 1:"; getline(cin,s1); // Reads string 1 till <Enter> key.
cout << "Text 2:"; getline(cin,s2); // Reads string 2 till <Enter> key.
cout << (areAnagrams(s1,s2)?"Are":"Are not") << " anagrams..." << endl; // Are they? We use the ternary operator.
return 0;
}
Explanation: included inside the code as comments.
Answer:
#include <iostream>
using namespace std;
void areAnagrams(char str1[], char str2[])
{
int i, flag = 1, count1[26] = {0}, count2[26] = {0};
for(i = 0; str1[i] != '\0'; i++) {
if (isalpha(str1[i])) {
str1[i] = tolower(str1[i]);
count1[str1[i] - 'a']++;
}
}
for(i = 0; str2[i] != '\0'; i++) {
if (isalpha(str2[i])) {
str2[i] = tolower(str2[i]);
count2[str2[i] - 'a']++;
}
}
for(i = 0; i < 26; i++) {
if (count1[i] != count2[i])
flag = 0;
}
if (flag == 0)
cout << "The two strings are NOT anagrams";
else
cout << "The two strings are anagrams";
}
int main ()
{
char str1[100], str2[100];
cout << "Enter the first string: ";
gets(str1);
cout << "Enter the second string: ";
gets(str2);
areAnagrams(str1, str2);
return 0;
}
Explanation:
Inside the function:
- In the first loop, each character of the first string is checked if it is a letter. If it is, lower the character and increment its frequency by 1.
- In the second loop, each character of the second string is checked if it is a letter. If it is, lower the character and increment its frequency by 1.
- In the third for loop, compare the frequencies
- If they are equal, that means the strings are anagrams
Write an efficient C++ function that takes any integer value i and returns 2^i ,as a long value. Your function should not multiply 2 by itself i times; there are much faster ways of computing 2^i.
Answer:
long power(int i)
{
return pow(2,i);
}
Explanation:
The above written function is in C++.It does not uses loop.It's return type is long.It uses the function pow that is present in the math library of the c++.It takes two arguments return the result as first argument raised to the power of second.
for ex:-
pow(3,2);
It means 3^2 and it will return 9.
The list method reverse reverses the elements in the list. Define a function named reverse that reverses the elements in its list argument (without using the method reverse!). Try to make this function as efficient as possible, and state its computational complexity using big-O notation.
Answer:
#code in python.
#function that reverse the element of list
def reverse(inp_lst):
for i in range(len(inp_lst)//2):
inp_lst[i], inp_lst[len(inp_lst) - i - 1] =inp_lst[len(inp_lst) - i - 1], inp_lst[i]
#main method
def main():
#create a list
lst1 = list(range(8))
print("list before revere:",lst1)
#call the method with list parameter
reverse(lst1)
print("list after revere:",lst1)
#create another list
lst2 = list(range(5))
print("list before revere:",lst2)
#call the method with list parameter
reverse(lst2)
print("list after revere:",lst2)
#call the main method
main()
Explanation:
In main method, create a list and call the method revers() with the list parameter. In the revers() method, swap the first element with last and second with second last. Similarly loop will run half the length of list.This will reverse the elements of the list.Then print the list before and after the revers in the main .Similarly we can test it for another list.
As the loop run for n/2 time in the method reverse(), so the complexity of the code is O(n).
Output:
list before revere: [0, 1, 2, 3, 4, 5, 6, 7]
list after revere: [7, 6, 5, 4, 3, 2, 1, 0]
list before revere: [0, 1, 2, 3, 4]
list after revere: [4, 3, 2, 1, 0]
What is the purpose of a destructor? (g) What is the purpose of an accessor?
Answer:
Destructor:-To free the resources when lifetime of an object ends.
Accessor:-To access private properties of the class.
Explanation:
The purpose of a destructor is to free the resources of the object that it has acquired during it's lifetime. A destructor is called once in the lifetime of the object that is also when the ifetime of the object ends.
The purpose of the accessors is to access private properties of the class.Accessor cannot change the value of the private members.They are also called getters.
Convert decimal number 126.375 to binary (3 bits after binary point)
Answer:
126.375 in binary is: 1111110.011
Explanation:
In order to convert a decimal number to binary number system, the integral part is converted using the division and remainder method while the fractional part is multiplied with 2 and the integral part of answer is noted down. The fractional part is again multiplied with 2 and so on.
For 126.375
2 126
2 63 - 0
2 31 - 1
2 15 - 1
2 7 - 1
2 3 - 1
1 - 1
So, 126 = 1111110
For 0.375
0.375 * 2 = 0.75
0.75 * 2 = 1.5
0.5 * 2 = 1.0
As we had to only find 3 digits after binary point, so
0.375 = 011
So 126.375 in binary is: 1111110.011 ..
. Convert 2AF from hexadecimal to binary. Show your work.
Answer:
The answer is 2AF₁₆ = 687₁₀ = 1010101111₂.
Explanation:
To convert from hexadecimal base system to binary base system, first you can do an intermediate conversion from hexadecimal to decimal using this formula:
[tex]N = x_1 * 16^0 + x_2 * 16^1 + x_3 * 16^2 + x_4 * 16^3+ ... + x_n 16^n^-^1[/tex]
, where position of the x₁ is the rightmost digit of the number and:
A = 10.B = 11.C = 12.D = 13.E = 14.F = 15.2AF₁₆ = 2*16²+A*16¹+F*16⁰ = 512 + 160 + 15 = 687₁₀
Now, transform from decimal to binary the number 687. Divide the number repeatedly by 2, keeping track of each remainder, until we get a quotient that is equal to 0:
687 ÷ 2 = 343 + 1;343 ÷ 2 = 171 + 1;171 ÷ 2 = 85 + 1;85 ÷ 2 = 42 + 1;42 ÷ 2 = 21 + 0;21 ÷ 2 = 10 + 1;10 ÷ 2 = 5 + 0;5 ÷ 2 = 2 + 1;2 ÷ 2 = 1 + 0;1 ÷ 2 = 0 + 1;Now, construct the integer part base 2 representation, by taking the remainders starting from the bottom of the list:
687₁₀ = 1010101111₂
Which of the following clauses of the UPDATE command is optional? (Points : 2) UPDATE
SET
WHERE
FROM
Answer:
FROM.
Explanation:
UPDATE table
SET column=value,column1=value1,.....
WHERE condition;
In the UPDATE command given in the question FROM is optional because when using UPDATE we already mention the table name with update look at the syntax above.So there is no need to again mention the table name in FROM.All other three are required that is UPDATE,SET,WHERE.
The method with the declaration public static char procedure(double d) has a method type of . a) public b) static c) char d) double
Answer:
Option(c) is the correct answer for the given question .
Explanation:
Public is the access modifier not a method type so option(a) option is wrong.
Static is not return type static keyword before the method of procedure means it is directly accessed with the help of class name so option(b) is also wrong.
double is the datatype of variable d it is not the method type so option(d) is also wrong
So char is the method type of the method procedure.
Therefore option (c) is the correct answer.
As data traverses a network, what address changes with each connection?
A: network B: transport C: physical D: MAC address
Answer: (D) MAC address
Explanation:
MAC address is the media access control address that basically used as identification number in the hardware. It is uniquely identified in the network for the every devices.
Whenever the packet moves from source to the destination the MAC address changes and updated with new destination and source MAC address. But it does not change its IP address during this process.
Therefore, MAC address basically change with the connection when there is data transverse in the network.
Describe the process of normalization and why it is needed.
Answer: Normalization is known as the process under which one organizes a database in order to improve data integrity and reduce redundancy. It also tends to streamlines database design in order to achieve optimal structure made up of the basic elements.
It is also referred to as data normalization, it is considered as a vital part of database design, since it helps with accuracy, speed and efficiency of database. By doing so, one can arrange data into columns and tables.
Discuss operations of vectors in computer graphics?
Answer:
In the computer graphics, the vectors are basically used to compose various type of components. In the computer graphics it is basically known as vector graphics and it is composed of various types of components.
The operation of the vector in the computer vector is that it is basically used to create the digital images by the use of mathematical statement and command.
It is used to place the lines and the shape in the two- dimension and three- dimension spaces. IN the computer graphics, vectors are also used to represent the particular direction of the various objects.
A remediation liaison makes sure all personnel are aware of and comply with an organization's policies.
True
False
Answer:
False.
Explanation:
I believe this should be the work of a compliance liaison. Assume you have opened up an organization that is growing each day. You have employees who are required to be compliant with all the security standards and policies. Hiring a compliance liaison will ensure that these compliances are being carried out. Each department in an organization should work with a compliance liaison to ensure that its employees understand and comply fully with all security policies.
controls to keep password sniffing attacks from compromising computer systems include which of the following?
a.Static and recurring passwords
b.Encryption and recurring passwords
c.One-time passwords and encryption
d.Static and one-time passwords
Answer:
the answer is b your welcome
What is the downside of wider channel bandwidth?
Answer: Wider channel bandwidth has several downside or disadvantages to it. Some of these are as follow:
a) Higher channel bandwidth means lower will be the number of channels being utilized.
b) Wider bandwidth may lead to an increase in the speed but on the other hand, it'll lead to several interference problems.
The ____________ is a very popular form of logic used to update a sequential file when three different types of transactions are present.
(Points : 2) match and delete rule
balance line algorithm
bilateral update algorithm
simplex sequential file rule
Answer: Simplex sequential file rule
Explanation:
The simplex sequential file rule is basically used to updated the given records in the form of order sequential file. It basically create new file which contain records that are already updated.
It contain three types of the transactions that is add, delete and change to updated the records in the sequential file. In the simplex sequential file, the transaction file records are same as the records in the master file.
On the other hand, all the given other options are incorrect because it does not involve in the transaction process.
Therefore, simplex sequential file rule option is correct.
Write a program that asks you to enter some integers, and press "enter" after each one.
There will be no set number of integers, and no need for data checking.
Entering the integer 0 will end the process of entering the integers
Answer:
// here is code in c++.
// headers
#include <bits/stdc++.h>
using namespace std;
// main function
int main()
{
// variables
int num;
cout<<"enter an integer (0 to stop):";
// read the integer
cin>>num;
// read integer until user enter 0
while(num)
{
cout<<"enter an integer (0 to stop):";
cin>>num;
}
//if input is 0 then print "exit"
cout<<"exit"<<endl;
return 0;
}
Explanation:
Declare a variable "num" to read input from user.Read input integer until
user enter 0 as input.When user enter 0 then program will print "exit" and
end the program.
Output:
enter an integer (0 to stop):2
enter an integer (0 to stop):-2
enter an integer (0 to stop):4
enter an integer (0 to stop):10
enter an integer (0 to stop):123
enter an integer (0 to stop): 0
exit
Create a C++ program that declares, initializes, and outputs the values contained in a two-dimensional array
Answer:
// here is code in C++.
#include <bits/stdc++.h>
using namespace std;
// main function
int main()
{
// variables
int r_size,c_size;
cout<<"enter the number of row:";
// read the value of row
cin>>r_size;
cout<<"enter the number of column:";
// read the value of column
cin>>c_size;
// create a 2-d array
int arr[r_size][c_size];
// read the value of array
cout<<"enter the elements of array:"<<endl;
for(int x=0;x<r_size;x++)
{
for(int y=0;y<c_size;y++)
{
cin>>arr[x][y];
}
}
cout<<"elements of the array are:"<<endl;
// print the array
for(int a=0;a<r_size;a++)
{
for(int b=0;b<c_size;b++)
{
cout<<arr[a][b]<<" ";
}
cout<<endl;
}
return 0;
}
Explanation:
Here we have demonstrate a 2- dimensional array. In which, how to read the elements and how to print elements of array.Read the value of row and column from user.Create a 2-d array of size r_sizexc_size. then read the elements of array either row wise or column wise. Then print the elements.To print the elements, we can go either row wise or column.
Output:
enter the number of row:2
enter the number of column:3
enter the elements of array:
1 2 3
2 3 4
elements of the array are:
1 2 3
2 3 4
What is meant by the term drill down?
Answer:
The drill down term is basically used in the information technology for the explore the multidimensional information or data by navigating the different layers of the data from the web page applications.
Drill down basically involve in the database by accessing the specific information through the database queries. Each query basically increase the data granularity. This term is also involve with the link for represent the details more specifically.
The drill down is the simple approach or technique for dividing the complex problems into small parts so that it make the technique more efficient.
Locker doors There are n lockers in a hallway, numbered sequentially from 1 to n. Initially, all the locker doors are closed. You make n passes by the lockers, each time starting with locker #1. On the ith pass, i = 1, 2,...,n, you toggle the door of every ith locker: if the door is closed, you open it; if it is open, you close it. After the last pass, which locker doors are open and which are closed? How many of them are open?
Answer:
// here is code in C++
#include <bits/stdc++.h>
using namespace std;
// main function
int main()
{
// variables
int n,no_open=0;
cout<<"enter the number of lockers:";
// read the number of lockers
cin>>n;
// initialize all lockers with 0, 0 for locked and 1 for open
int lock[n]={};
// toggle the locks
// in each pass toggle every ith lock
// if open close it and vice versa
for(int i=1;i<=n;i++)
{
for(int a=0;a<n;a++)
{
if((a+1)%i==0)
{
if(lock[a]==0)
lock[a]=1;
else if(lock[a]==1)
lock[a]=0;
}
}
}
cout<<"After last pass status of all locks:"<<endl;
// print the status of all locks
for(int x=0;x<n;x++)
{
if(lock[x]==0)
{
cout<<"lock "<<x+1<<" is close."<<endl;
}
else if(lock[x]==1)
{
cout<<"lock "<<x+1<<" is open."<<endl;
// count the open locks
no_open++;
}
}
// print the open locks
cout<<"total open locks are :"<<no_open<<endl;
return 0;
}
Explanation:
First read the number of lockers from user.Create an array of size n, and make all the locks closed.Then run a for loop to toggle locks.In pass i, toggle every ith lock.If lock is open then close it and vice versa.After the last pass print the status of each lock and print count of open locks.
Output:
enter the number of lockers:9
After last pass status of all locks:
lock 1 is open.
lock 2 is close.
lock 3 is close.
lock 4 is open.
lock 5 is close.
lock 6 is close.
lock 7 is close.
lock 8 is close.
lock 9 is open.
total open locks are :3