answersLogoWhite

0

What else can I help you with?

Related Questions

Explain the concept of interfaces in java with a suitable example for the same?

interface works like an abstract class it has methods which are not defined its job is to give a general idea about the class(generic) the class can have its own functions but interface makes java program to include all the functions or methods present in the interface there are ibuilt interfaces like runnable example in threads it is runnable it makes compulsory to the class to include all the methods in interface if you dont want that then use abstract key word before class eg: interface a{void meth(int i);} class one implements a{ void meth(int i) System.out.print(i); //all other members of class// if dont use meth function it will give an error for big projects certain general functions are necessary which have to be there everywhere it gives general idea of what the program is doing


Simple example in interface?

Any device or construct that allows a human being to interact with a machine is an interface. The steering wheel of a car is an interface, the play button on a DVD video player is an interface, the close icon on a window is an interface, the CTRL+C accelerator is an interface, and so on.


What is the use of interfaces extension through inheritance?

Interfaces are extremely useful in creating inheritance hierarchies in java programs. Interfaces cannot be extended but they will be implemented. Ex: public Interface Interface1 { public String getName() {}; } public Interface Interface2 { public int getAge() {}; } public class InterfaceExample implements Interface1, Interface2 { public String getName() { return "Anand"; } public int getAge() { return 28; } } Here I have implemented two interfaces in a class. I must provide implementation for all the methods that are declared inside both interfaces. So for simplicity I have just written 1 method in each interface but in practical situations you may have numerous methods inside each interface.


What program can be written to count the number of alphanumerics in a string?

public int getStringLength(String val) { return val.length(); } There is an inbuilt functionality in strings that counts the number of alphabets in a string called length()


Write a program that converts a string from small letters to capital letters and vice versa?

Here's a Python program that accomplishes this: def convert_case(input_str): return input_str.swapcase() user_input = input("Enter a string: ") converted_str = convert_case(user_input) print("Converted string:", converted_str)


How do you get value of a string in reverse order in c?

Assume C#, not C: Traditional way: public string Reverse(string s) { if (string.IsNullOrEmpty(s)) return s; // "" or null char[] characters = s.ToCharArray(); Array.Reverse(characters); return new string(characters); } or as an extension method: public static string Reverse(this string s) { if (s == "") return ""; char[] characters = s.ToCharArray(); Array.Reverse(characters); return new string(characters); } The differences of the 2 methods above is on the caller (how to use Reverse()), and they may co-exist: For example: string test = "abc"; string result1 = Reverse(test); // traditional way string result2 = test.Reverse(); // call the extension


Write a program to concate the string without using strconcat function?

If you don't need to preserve the first string you could just iterate over the second string and copy each character onto the end of the first string, then return that


What is a function in java?

The term equivalent to functions in Java is "methods". Methods are pieces of code that are used to make some functionality. Ex: public String getName(){ return "Anand"; } The above is a sample method


Program to find the size of the string in c?

int main (void) { char buf[1024]; scanf ("Enter a string: %s", buf); printf ("The length of the string is %d chars long.\n", strlen (buf)); return 0; }


In a java program in a return statement with string concatenation how do you print a blank line?

use "\n" between the words where you want a new line


Program in c string length in window using array?

size_t my_strlen (const char str []){size_t i;for (i=0; str[i]; ++i);return i;}


How do you retrieve data from database using struts 2?

package com.kmg.services;public class Employee {private String empNo;private String password;private String fName;private String mName;private String lName;private String dept;private String desig;private String address;public String getempNo() {return empNo;}public void setempNo(String empNo) {this.empNo = empNo;}public String getpassword() {return password;}public void setpassword(String password) {this.password = password;}public String getfName() {return fName;}public void setfName(String name) {fName = name;}public String getmName() {return mName;}public void setmName(String name) {mName = name;}public String getlName() {return lName;}public void setlName(String name) {lName = name;}public String getDept() {return dept;}public void setDept(String dept) {this.dept = dept;}public String getDesig() {return desig;}public void setDesig(String desig) {this.desig = desig;}public String getAddress() {return address;}public void setAddress(String address) {this.address = address;}}