Interface in java
Hello ! i m a beginner in java .Kindly help me to solve these questions
Which of the following statements will compile without error?
interface IFaca{}
class CFace implements IFace{}
class Base{}
public class ObRef extends Base{
public static void main(String argv[]){
ObRef ob = new ObRef();
Base b = new Base();
Object o1= new Object();
IFace o2 = new CFace();
A. o1=o2;
B. b=ob;
C. ob=b;
D. o1=b;
Options----
1. A,B,D
2. A,B,C
3. B,C,D
4. D,C,A
hi Payal,
In this case Option 1 is correct.
Please assign points if it is helpful.
Regards,
Richa.
Similar Messages
-
What is the diffrence between My Runnable Interface and Java Runnable
Hi folks
all we know that interfaces in java just a decleration for methods and variables.
so my Question is why when i create an interface its name is "Runnable" and i declared a method called "run" inside it.then when i implements this interface with any class don't do the thread operation but when i implement the java.lang.Runnable the thread is going fine.
so what is the diffrence between My Runnable Interface and Java Runnable?
thnxHi folks
all we know that interfaces in java just a decleration
for methods and variables.
so my Question is why when i create an interface its
name is "Runnable" and i declared a method called
"run" inside it.then when i implements this interface
with any class don't do the thread operation but when
i implement the java.lang.Runnable the thread is going
fine.
so what is the diffrence between My Runnable Interface
and Java Runnable?
thnxClasses and interfaces are not identified by just their "name", like Runnable. The actual "name" the compiler uses is java.lang.Runnable. So even if you duplicate the Runnable interface in your own package, it's not the same as far as the compiler is concerned, because it's in a different package.
Try importing both java.util.* and java.awt.* (which both have a class or interface named List), and then try to compile List myList = new ArrayList(); -
Need Info Regarding Implementaion of Interfaces in java.sql package
Hi All,
I am interested in knowing details abt how the Interfaces in the java.sql package are implemented. We all work with the database using the interfaces provided ,but how do they work at the backend ? How can a Interface provide details (work ) with out an implementation class.I Is this taken care by the JVM or some of the Call level interfaces? Please do provide details abt this..hi Sheshadri,
The implementation of the various interfaces in
java.sql package are provided by your jdbc driver,
which also manages the connection and communication of
your java program with the appropriate database.
cheers,
-Jer -
I have a doubt about interfaces. All interface in Java has empty methods, I mean,the methods dont have any implementation. So, to use these methods, there has to be a class that implements this interface in order these methods to have an implementation. Here is my question: there are some Interfaces in Java like java.sql.Statement that dont have any class that implements its methods and in spite of this, I can call the methods of the interface. How is this possible?
ThanksYes there is always an implementation. You just aren't necessarily exposed to the actual class which implements the interface, but you can tell what the class is like this:
Statement stmt = ...; // get your Statement however you are doing it now
System.out.println("Actual class implementing Statement interface in this case is: " + stmt.getClass()); -
Templates in c++ vs interface in java
What is the advantage of using interface in java than use of templates in C++
They are not comparable. In any case, the language you chose will determine which one you can use, so this is not a choice.
When comparing templates, the closest in java is generics. If this is what you meant, I suggest you look at some of these
[http://www.google.co.uk/search?q=templates+vs+generics] 1,440,000 hits covers this topic fairly well. -
Is anyone know how to run the examples in 3d user interfaces with java 3d
hi dear ,
I am trying to run the examples in 3d user interfaces with java 3d.
I hope i can load the library in jcreator. but the libarary for this book are classes files , it do not have jar file for it . the jcreator do not read these classes . i do not know why ? i am wonder if there any one run these code before can give me some idear .
thanks so much .
the code u can get from this link.
http://www.manning.com/books/barrilleaux/source
thank you for u to have a look for me .
regards
xiaocui<h2>{color:red}CROSS POSTED{color}</h2>
[t-5289810]
Cross posting is rude.
db -
Interfacing a java program with hardware
I need to be able to interface a java program
with data in the parallel or serial ports of the computer.
I have no idea how to go about this, could someone please help me.
Thankshttp://java.sun.com/products/javacomm/
-
What is Markable Interface in JAVA
What is Markable Interface in JAVA need explanation
Markable interface in one which does not contain any
method or member declaration.
Eg: Serializable, Observable etc...terminology aside, I don't think "not containing any methods" is enough to call something a marker interface. is EventListener a marker interface? I don't think so, I think of it as a supertype for all other event listeners in the JDK -
Can I call an interface from java
Dear All,
Can I call an interface from java in ODI ?
Best Regards
ArcShort answer, Yes.
Long answer - you must create a scenario from the interface (the scenario is the "executable" code), right-mouse-button on the interface in the tree and "Generate Scenario". This can then be called using the invocation api this is documented in your <installationdirectry>/oracledi/doc/sdk/invocation. This points you at all the necessary classes etc to use. -
Any gui interface for java db (derby ) such as oracle give sqldeveloper
hi master
sir any gui interface for java db (derby ) such as oracle give sqldeveloper that create table and view only mouse clicking
how i get derby gui interface
thank'
aamirtry db visualizer
http://www.minq.se/products/dbvis/ -
Using native interfaces in java
How can you use a native interface in java?
1) By reading the JNI api and writing appropriate code or
2) Stealing some code already done to get you started
(#2 is VERY popular)
And, oddly enough, I have posted 2 articles on here about using JNI in the last few weeks. So, do a search for "smg123 JNI" and you'll find my posts. -
Difference between interfaces in Java API and user defined interfaces
Is there any differences between the interfaces (such as KeyListener, ActionListener and EventListener etc.,) in Java API and the user defined interfaces.
The user defined interfaces seems to be empty without any functionality (except its constant and method declarations). But the interfaces in Java API seems to have some functionality behind them, since they route the device events to the programs.
Actually what is happening behind the Java API's interfaces?
Please clarify.Ummm, no they are not (or at least some of them are not). Also, some things we support now we may not have supported in a previous release.
If you look at the section 2 (Working with TimesTen Data Stores0 in the TimesTen Java Developer's Guide and look at the sections:
TimesTen JDBC Extensions
Additional TimesTen classes and interfaces
then you will see the extra functionality documented there. Of course, if you do not need any of this functionality then you can simply treat them as the base classes from java.sql and they will work fine so it is easy to make most of your code generic.
Chris -
Using component interface in Java
i know working and programming with component interface but no knowledge about java
please give me steps to use component interface in java.
Shiv1. Identify/Create Component Interface which you want to access in Java
2. Apply security for your Component Interface
3. Open the Component Interface in Application Designer
4. In Application Designer, select Build > PeopleSoft APIs
5. A dialog box comes with caption "Build PeopleSoft API Bindings"
6. Select Build checkbox for Java Classes Frame and give a target directory
7. Select OK, This will generate PeopleSoft API classes, dont panic if it takes some time
8. Right click on component interface, select Generate Java Template, this step will generate Java Template
9. If you are not familiar with compiling and setting up CLASSPATH in Java then it is better you ask any of your colleagues who knows Java.
10. Once CLASSPATH is set properly you can compile the generate Java Template without any problems
11.after compilation you will get a .class file and you need to execute that .class file
12. When you execute the .class file it will ask application server name, application server port, application user name and application password.
If you give all the information correctly then you will be accessing CI in Java.
Let me know if you need more help on this.
Jayaprakash Tedla -
One of them uses Enterprise Java Beans implemented with a SUN NetDynamics application server. The other is a straight Java application. Ideally I want the second application to remotely invoke methods on the existing Java beans, so the existing business logic will not be duplicated.
This would seem to be simple, but NetDynamics appears to substitute some proprietary code for part of the EJB interface, and it is not immediately obvious how to let "foreign" java programs access the beans.
I would appreciate it if anyone is able to provide any information on how to achieve this. If you know of any sample code that I could look at, that would be a help too. This may (or may not) be known to SUN as a "stand alone java client".hi,
can someone help me how to implement logging for method entry parameters and
method exit return value.
can someone help me how to use log4j and integrate it to the method entry
logging and method exit logging.
Here what i need is without writing the log statements for the method entry and
method exit i need to log it to the file
along with other log4j debug statements i provide in the file.I should be able
to configure whether to enable/disable the logging
for method entry and method exit. In method entry i should be able to log the
parameters the method take and in method exit
i should be able to log te return value to the log file, before the method is
returned to the callee.
i hope i am clear
Thanks in advance. -
A question about share interface in java card
I meet a big problem in java card recently.
I try to develop a loyalty and a purse in the JCOP 20 . I use the share interface to share data between two applets.At first I write two small applets to test the share interface.Then I manully dowon the two applets into the card but it doesn't work. The error always happen to the "getAppletShareableInterfaceObject" method.
Following is part of the code.
buffer[0]=(byte)0x06; buffer[1]=(byte)0x05; buffer[2]=(byte)0x04; buffer[3]=(byte)0x03; buffer[4]=(byte)0x02; buffer[5]=(byte)0x01; buffer[6]=(byte)0x01;
//server applet ID
AID loyaltyAID2 = JCSystem.lookupAID(buffer, (short) 0,(byte)7);
if(loyaltyAID2==null) ISOException.throwIt((short)0x0902);
loyaltySIO = (JavaLoyaltyInterface) JCSystem.getAppletShareableInterfaceObject(loyaltyAID2,(byte)0);
//...........................................error happen in this line
I try to find the error I find the error, so I trace to the server applet,I add a "ISOException.throwIt " method in the getShareableInterfaceObject in the server applet.
I find if I add it,the "getAppletShareableInterfaceObject" will return but get the null object.
It's correct.But when I remark the "ISOException.throwIt" and just return "this" ,the card will get "6F00".
Following is my code.
public Shareable getShareableInterfaceObject(AID clientAID,byte parameter)
//ISOException.throwIt((short)0x9999);
return this; } error happen in this line
TKS...Yes I did do it,I modify the sample code of the SUN micro's loality and purse .Following is my source code.
Client code(purseeasy).......
//=========================
package purseeasy;
import com.sun.javacard.samples.JavaLoyalty.JavaLoyaltyInterface;
import javacard.framework.*;
public class purseeasy extends javacard.framework.Applet
private byte[] echoBytes;
private static final short LENGTH_ECHO_BYTES = 256;
public purseeasy()
echoBytes = new byte[LENGTH_ECHO_BYTES];
register();
public static void install(byte[] bArray, short bOffset, byte bLength)
new purseeasy();
public void process(APDU apdu)
byte buffer[] = apdu.getBuffer();
short bytesRead = apdu.setIncomingAndReceive();
short echoOffset = (short)0;
switch(buffer[2])
case 0x31:
AID loyaltyAID1 =JCSystem.getAID();
short i=loyaltyAID1.getBytes(buffer,(short)0);
if(loyaltyAID1==null)
ISOException.throwIt((short)0x0901);
buffer[0]=(byte)0xd1;buffer[1]=(byte)0x58;
buffer[2]=(byte)0x00;buffer[3]=(byte)0x00;
buffer[4]=(byte)0x01;buffer[5]=(byte)0x00;
buffer[6]=(byte)0x00;buffer[7]=(byte)0x00;
buffer[8]=(byte)0x00;buffer[9]=(byte)0x00;
buffer[10]=(byte)0x00;buffer[11]=(byte)0x00;
buffer[12]=(byte)0x00;buffer[13]=(byte)0x00;
buffer[14]=(byte)0x31;buffer[15]=(byte)0x00;
AID loyaltyAID2 = JCSystem.lookupAID(buffer,
(short)0,(byte)16);
if(loyaltyAID2==null)
ISOException.throwIt((short)0x0902);
JavaLoyaltyInterface loyaltySIO =
(JavaLoyaltyInterface)
JCSystem.getAppletShareableInterfaceObject(loyaltyAID2,(byte)1);
if(loyaltySIO ==null)
ISOException.throwIt((short)0x0903);
loyaltySIO.grantPoints (buffer);
break;
apdu.setOutgoingAndSend((short)0, (short)18);
//=====================================
//Server program....share interface
package com.sun.javacard.samples.JavaLoyalty;
import javacard.framework.Shareable;
public interface JavaLoyaltyInterface extends Shareable
public abstract void grantPoints (byte[] buffer);
//=============================================
//Server program....loyalty
package com.sun.javacard.samples.JavaLoyalty;
import javacard.framework.*;
public class JavaLoyalty extends javacard.framework.Applet implements JavaLoyaltyInterface
public static void install(byte[] bArray, short bOffset,
byte bLength)
{new JavaLoyalty(bArray, bOffset, bLength);
public JavaLoyalty(byte[] bArray, short bOffset, byte
bLength)
register();
public Shareable getShareableInterfaceObject(AID
clientAID,byte parameter)
return (this);
public void process(APDU apdu)
byte buffer[] = apdu.getBuffer();
short bytesRead = apdu.setIncomingAndReceive();
apdu.setOutgoingAndSend((short)0, (short)18);
public void grantPoints (byte[] buffer)
buffer[0]=0x08;
buffer[1]=0x08;
buffer[2]=0x08;
buffer[3]=0x08;
buffer[4]=0x08;
buffer[5]=0x08;
buffer[6]=0x08;
buffer[7]=0x08;
Could you tell me what wrong with my code???
Thanks.... -
I need some help with Interfaces since I'm really new to OOP.
I have 1 interface, 1 class implementing the interface and 1 main function. Here is the structure:
public interface t_action
public boolean isvalid(int a, int b);
public class sec implements t_action
public boolean isvalid(int a, int b)
/* Implmentation of this method */
public class main()
public static void main(string args[])
boolean valid = false;
/* Need to call isvalid in public class sec
and assign it to the "valid" variable above
}My Question is:
How do i call the method "isvalid" in class sec that implements the t_action interface? I need to assign it to my variable "valid" in class main
Any help is appreciated.
Thanks.
MAZ@McMaster EngineeringHey all...
Thanks for your contribution.
As I said earlier here: "I'm new to Java" so cut me some slack!!!
I've been doing C programming all my life so java is similar but quite foreign to me since I started learning it recently on my own
If this were a normal class and not an interface, it would be:
class_name myclass = new class_name();
myclass.isvalid(a, b);But why is it:
interface_name i = new class_implementing_interface();
i.isvalid(a,b);Thanks
Maybe you are looking for
-
Downloading iPhone 3GS photos and Videos to other computers
I recently got my first iPhone and am still finding out how to do things, so, apologies if this sounds dim but.... How do I download photos and videos from my iPhone 3GS to other computers? I can plug in to my mac and sync everything with iTunes - no
-
MS SQL server is going down frequently(10 days of gap) with exception message: "A severe error occurred on the current command. The results, if any, should be discarded". We are facing this issue for past two month.But funny thing is server will be u
-
Getting error while starting Managed server configured in ALSB(ClusteredEnv
Hi All, I configured Custered environment in Weblogic 9.2 to use in ALSB. While starting managed server i am getting error : <Critical> <WebLogicServer> <punitp46462d> <new_ManagedServer_1> <Main Thread> <<WLS Kernel>> <> <> <1233666363188> <BEA-0003
-
Simple credit check - value need to be blocked from particular sales order to be post in f.35
Dear Expert, I have a case here to find, the client uses simple credit check , we have different order types ( Example 6 order types), out of which we want to restrict the value of one order type to be posted in f.35 i.e the value should not effect c
-
Mac OS 10.5 display sleep
Dear reader, Since I yesterday updated my Flash Player on Mac OS 10.5 to the latest version I encounter a strange and annoying problem. Before when a Browser window with a Flash stream was not maximized the display sleep option would activate at the