100 metres seems to be the length of a spool of gardeners cotton Discuss:How_long_is_a_piece_of_string...we are not talking about jute twine here!So the maximum length of a piece of string would be 999.99mm!So the real answer to 'how long is a piece of string?' would be...anything between 0.01mm to 999.99mm.
What are the steps to add a menu to a frame in advance java?
step 1:
create menubar object and set it
step 2:
create menu objects with parameterized constructor
step 3:
add menus to menubar
How many bytes in an address of an int variable?
32 bits or 4 bytes and an int is not an address, it is a primitive so it directly access the data without a reference.
What programming languages are used in programming an EEPROM?
In one sense, since EEPROM is memory, you don't program memory. You store things in memory, and the thing you are programming in this case would likely be a micro-processor or micro-controller that is on the same circuit as the EEPROM.
In theory, an EEPROM is just memory, so any language that would be able to produce machine language output for the CPU type connected to the EEPROM in any instance could be used.
In practice, many programs written to EEPROM would be for embedded systems. In this case, a lower level language like C could be used, or a higher level language that output C or the right kind of assembly.
A higher level language like C# or Java would likely not be used, as the overhead of the virtual machine might be considered to be too heavy for a micro-controller, or small micro-processor.
That being said, in practice, you could use anything. But it is likely you would have some libraries in C or C++ that you might want to use, so you would likely use a language that was compatible with any libraries you might use.
yah it's correct.
The error "Connection reset by peer" is a TCP error that occurs when a server sends your application a RST (i.e. reset) packet which terminates the TCP connection between you and the server.
You can retry manually and maybe the server will not reset you, but if you keep getting this there is not much you can do. It is the equivalent of slamming the phone back on the hook abruptly instead of politely saying goodby and gently hanging up.
Which comma is used for characters in switch case statements?
There is only one comma, but it is not used in switch-case. Character literals are between apostrophes: 'x'
What is the difference between Java bean and bean?
JAVA beans and coffee beans are two very different things . JAVA beans are used to generate getters and setters. while coffee beans are use to make coffee.
Why is cyclic inheritance not in any programming language?
Cyclic inheritance is physically impossible. A base class cannot inherit from one of its own derivatives any more than you could inherit some generic trait from one of your own descendants. Inheritance is strictly a one-way street.
How should you design a scientific calculator using C plus plus?
The easiest way to implement a calculator is an RPN calculator (enter the numbers first, perform the operation last). You need a last-in-first-out stack (there's a "stack" class in C++, but you can also implement your own using an array or a linked list), and a set of functions that pop the last elements from the stack and push the result (e.g. Add() pops the last 2 values and pushes their addition).
You'll need the math.h library for scientific operations.
How do you remove a column from JTable?
ColumnModel columnModel = table.getColumnModel();
for(Column: columnModel.getColumns()) {
Column column = <FIND COLUMN YOU NEED>;
}
columnModel.removeColumn(column);
Is it necessary to read or display the elements of an array in order of its subscripts?
By no means; you can access any random array element. If you have ever seen examples which process them in order, it is because of the following: when the order doesn't matter (for example, you want to calculate the sum of all the array elements), it is easiest to process them in order.
What translates a Java program into Bytecode?
The Java Runtime Environment (JRE) converts the byte code to machine language.
What is the purpose of the black code?
the main purpose of the legislation was to stabilize the black workforce by compelling African Americans to work and by limiting their economic options … The laws aimed to replace the social controls of slavery, which had been legally swept away by the Emancipation Proclamation and the Thirteenth Amendment, and to reinstate the substance of the slave system without the legal form.
Can a derived class call the static constructor of a base class in .Net?
No. not directly.
The static constructor is called by .net framework, not by your code.
I always treat static constructor is the class initializer (not the instance one). The initialization routine is only called when the class definition being loaded.
When the derived class is loaded, since this class derived from the base, it makes to go up the chain (of the hierarchy) to call those static constuctors.
So, when a derived class is loaded, the static constructors of the hierarchy is called up. (any one of them had been loaded, the calling sequence stops).
You cannot call those static constructor directly, nor you can skip "not to execute" them.
Can a method be declared in any order in a class?
Yes. There is no specific order in which the compiler expects methods to be present. As long as the method is inside the class it is perfectly fine.
Given an int array length 2 return true if it contains a 2 or a 3.?
public boolean has2or3(int[] nums) {
if ( nums[0] 3 )
return true;
return false;
}
Yes using the equals method.
Example:
Double a = new Double(Double.NaN);
Double b = new Double(Double.NaN);
if( a.equals(b) )
System.out.println("True");
else
System.out.println("False");
If you execute the above code snippet you will see "True" in the console. If you try the "==" operator to compare the 2 values a and b you will get only false
How do you create an object for anonymous class?
public class Class1 {
protected InnerClass1 ic;
public Class1() {
ic = new InnerClass1();
}
public void displayStrings() {
System.out.println(ic.getString() + ".");
System.out.println(ic.getAnotherString() + ".");
}
static public void main(String[] args) {
Class1 c1 = new Class1();
c1.displayStrings();
}
protected class InnerClass1 {
public String getString() {
return "InnerClass1: getString invoked";
}
public String getAnotherString() {
return "InnerClass1: getAnotherString invoked";
}
}
}
we can do like . crieate inner class instanve in side of main class defalut consiter . use the object we do the our bz logic
WAP to initilize a character and print whether it is a vowel or not?
// short version
char c = 'a';
System.out.println((c=='a'c=='e'c=='i'c=='o'c=='u')?"VOWEL":"CONSONANT");
// easy to read version
char c = 'a';
switch (c) {
case 'a':
case 'e':
case 'i':
case 'o':
case 'u':
System.out.println("VOWEL");
break;
default:
System.out.println("CONSONANT");
}
What is the difference between classes and objects?
Class
Defines the abstract characteristics of a thing (object), including the thing's characteristics (its attributes, fields or properties) and the thing's behaviors (the things it can do, or methods, operations or features). One might say that a class is a blueprint or factory that describes the nature of something. For example, the class Dog would consist of traits shared by all dogs, such as breed and fur color (characteristics), and the ability to bark and sit (behaviors). Classes provide modularity and structure in an object-oriented computer program. A class should typically be recognizable to a non-programmer familiar with the problem domain, meaning that the characteristics of the class should make sense in context. Also, the code for a class should be relatively self-contained (generally using encapsulation). Collectively, the properties and methods defined by a class are called members.
Object
A pattern (exemplar) of a class. The class of Dog defines all possible dogs by listing the characteristics and behaviors they can have; the object Lassie is one particular dog, with particular versions of the characteristics. A Dog has fur; Lassie has brown-and-white fur.
A class is the type definition of an object. An object is an actual instance of a class type.
What is the difference between mutuator and accessor methods?
Mutator: Put something into the class (change something). By convention, has a name that starts with "set", for example, "getName".
Accessor: Get something out of the class (find out the class's state). By convention, has a name that starts with "get", for example, "getName". For logical values, "is" is used instead, for example, "isActive".
Can you answer in this java programming quiz? just 1 or 2 answers are fine..
1. The != operator is used to evaluate _______ between two values.
Non-equality
!!
=!
Equality
2. The interface part of a class is created using
package access
protected visibility
private visibility
3. User defined data type or objects (like a Car class object) are passed by
Reference
Value
Copy
Placement
5 . If you declare constructors private, they ________ be called by all classes and methods to create objects.
Can
can privately
can virtually
Can t
6. Components are placed in a container by calling the __________ method.
registerComponent ()
addActionListener ()
setLayout ()
add ()
7. If an abstract method is not defined in a subclass, the subclass is
Abstract
Overridden
Promoted to the superclass
Hidden
8. Subclass objects of different type that inherit from the same superclass
Can be treated as superclass objects
Can't share private superclass data
Don't share the same superclass data
Don't share any data
9. Polymorphism
Promotes and allows sharing of data and methods between classes
Allows development of general solutions and the runtime selection of methods
Prevents methods outside a class from directly accessing instance variables
Allows classes to contain/combine both data (properties) and methods (behaviors)
10. Inheritance relationships form _________.
Hierarchical Structures
Peer to Peer Networks
Loosely bounded sets
Network Structures
11. Your program class that inherits from JPanel ____________.
Uses a constructor to initialize objects
Inherits the behavior of a JObject program
Is unable to override paint_component ()
Knows nothing of drawing
12. The paint_component method ___________.
Must be private
Expects a Graphics object argument
Never calls super.paint_component (g)
Must be called by you
13. Successful use of polymorphism depends on
Identifying generic methods
Identifying an inheritance class composition
Identifying abstract objects
Deciding on how to use subclass references
14. A superclass method can be overridden in a subclass in order to
Change the name
Make the method private
Provide new behavior appropriate to the subclass
Allow hidden access
16 . In order to place subclass objects of different type in an array
They must inherit from the same subclass
The array reference itself must be of superclass type
You must cast and add-in missing superclass members
They must be of the same type
17. The name of the event handler method of the ActionListener interface is ____.
itemStateChanged
mouseMoved
actionPerformed +
keyPressed
18. Downcasting
Converts a subclass reference to a superclass reference
Converts a subclass object to a superclass object
Converts a superclass reference to a subclass reference
Converts a superclass object to a subclass object
19. A simple layout manager is the ____ manager.
GridLayout
BoxLayout
FlowLayout
PanelLayout
20. An individual array element is accessed using its _________.
Type
Subscript/Index
Value
Object
21. Since it generates byte codes, the Java compiler is _________.
An interpreter
Not a true compiler
Object code
Windows instructions
22. When GUI components are displayed on the screen, a/an ___________ positions and displays those components.
Layout manager
Container object
Event handler
Interface class
23. An executing program class must contain a/an
Body
Main method
Instance variable
Comment
24. Referring to a superclass object through a subclass reference
Can cause a runtime error
Requires that the superclass reference refers to the same subclass object as the cast
Requires an explicit object to avoid the compilation error
25. Polymorphism works for
Unrelated classes
Overloaded classes
An inheritance hierarchy of classes
Has-a classes
26. Given that a=4, b=10, c=2, d=5, and x=3, the expression "(a + c) / c * d + a" evaluates to
20
4
128
19+
27. When dynamic binding takes place, the Java system
Determines the type of the object at compile time
Binds a method name to its address at runtime
Moves up the inheritance hierarchy
Makes a list of generic event handlers
28. When dynamic binding takes place, the Java system
Determines the type of the object at compile time
Binds a method name to its address at runtime
Moves up the inheritance hierarchy
Makes a list of generic event handlers
29. If a subclass constructor explicitly calls a superclass constructor
It overrides the superclass constructor
It must call the noarg constructor
It cannot access protected data
The call must be the first line of code
30. The composition relationship can be identified as a/an _________ relationship.
Enduring
Has/a
Is/a
Overridden
31. When declared with a static lifetime,
Variables exist during the execution of a method
Variables exist from beginning to end of program execution
Methods and instance variables are visible
Variables declared outside the {} of a block
32. When an array is passed as an argument to a method, _____.
The array is passed by reference
Only the first value is passed
The called method can't change array values
It is passed by value
33. When the expression "result = total + input * 2;" is evaluated the __________ is placed in the location of the left hand side.
Left side result
Assignment
Right side result
Operator
34. When invoked, a subclass constructor
Automatically calls the noarg constructor of the superclass (if one is not explicitly called)
Cannot access superclass data even if protected
Returns a superclass object
Does not use the superclass constructor
35. When declared with automatic scope,
Variables exist during the execution of a method
Variables exist from beginning to end of program execution
Methods and instance variables are visible
Variables declared outside the {} of a block
36. The inheritance class relationship
Promotes and allows sharing of data and methods between classes
Allows development of general solutions and the runtime selection of methods
Prevents methods outside a class from directly accessing instance variables
Allows classes to contain/combine both data (properties) and methods (behaviors)
37. When a subclass method has the same name and type as a superclass method but accepts different arguments, that's an example of
Protected inheritance
Overriding
Polymorphism
Overloading
38. When you want to declare constant values, you would use the ________ keyword.
objects
final
const
Static variables
39. The toString method
Is not provided by class Object
Is called implicitly to convert an object to a String
Can be overloaded
Can't be overridden
40. A switch statement tests a variable or expression against __________.
Constant, integral values
Expressions
Decimal numbers
Strings
41. Reffering to a superclass object through a subclass reference
can cause a runtime error
Requires that the superclass reference refers to the same subclass object
Requires an explicit object to avoid the compilation error
48. Because all variables must be declared before their use, Java
Is an object oriented language
Is a strong variable language
Is a strongly typed language
Is a typing language
49. Variables declared/defined inside a method are
General variables
Visible everywhere
Local variables
Instance variables
50. The while statement
Is the most specific form of repetition
Requires initialization, test, and change of a control variable
Will never skip execution of the loop body
Doesn't use a control variable
51. The do-while statement
Does not require a test of cond
Is the most specific form of repetition
Executes at least once
Is intended to replace for statements
52. The use of superclass references to refer to subclass objects has been found useful
For container objects
When placing elements of subclass objects in a superclass array
When placing elements of superclass objects in a subclass array
For Composition classes
53. Overloaded constructors are used to
Create different types of objects
Create two dimensional arrays
Create primitive data types
Initialize objects of the same class in different ways
54. Java's mechanism for placing related classes in a subdirectory uses the ________ keyword.
package
import
extensible
extends
55. this
is a reference to an object
Can t be used to access object data
Is passed to every class
Is hidden and private
56. An anonymous inner class ____.
Has a class name
Typically is used to define an event handler class
Has no scope
Contains anonymous methods
57. The new operator is used to __________.
Allocate memory for an object or array
Call an object destructor
Call the garbage collector
Promote visibility
58. The drawOval method takes the same four arguments as ________.
drawLine ()
drawPoly ()
drawRect ()
fillArc ()
59. In order for a class method to access the private data of a class object (not of its class)
The data can only be read
It can't
The data can be changed directly
get/set methods must be used
Question 62
62. Class methods ________ access all class variables, public or private.
Can
Can't
64. A reference in a Java program
Causes object initialization
Refers or points to a runtime data type
Causes memory allocation
Refers (or points to) to an object
65. The listener interface for radio buttons is the ____ interface.
ActionListener
MouseListener
KeyListener
ItemListener
66. implementation part of a class is created using
67. What types of superclass methods/variables can be directly accessed from a sub class?
public
private
provoked
68. The statement(s) in the body of an if structure should be indented in order to
Compile properly
They shouldn t
Stand out and enhance readability
Allow repetition
69. The sdk program that is the JVM and runs programs is
java
javac
appletviewer