karthikeya Boyini

karthikeya Boyini

1,421 Articles Published

Articles by karthikeya Boyini

Page 103 of 143

How to compare two variables in an if statement using Python?

karthikeya Boyini
karthikeya Boyini
Updated on 05-Mar-2020 6K+ Views

You can compare 2 variables in an if statement using the == operator. examplea = 10 b = 15 if a == b:    print("Equal") else:    print("Not equal")OutputThis will give the output −Not EqualYou can also use the is the operator. examplea = "Hello" b = a if a is b:    print("Equal") else:    print("Not equal")OutputThis will give the output −EqualNote that is will return True if two variables point to the same object, == if the objects referred to by the variables are equal.

Read More

Do you think Python Dictionary is really Mutable?

karthikeya Boyini
karthikeya Boyini
Updated on 05-Mar-2020 299 Views

Yes, Python Dictionary is mutable. Changing references to keys doesn't lead to the creation of new dictionaries. Rather it updates the current dictionary in place. examplea = {'foo': 1, 'bar': 12} b = a b['foo'] = 20 print(a) print(b)OutputThis will give the output −{'foo': 20, 'bar': 12} {'foo': 20, 'bar': 12}

Read More

How can we combine multiple print statements per line in Python?

karthikeya Boyini
karthikeya Boyini
Updated on 05-Mar-2020 5K+ Views

You can combine multiple print statements per line using, in Python 2 and use the end argument to print function in Python 3.examplePython2.x print "Hello", print " world" Python3.x print ("Hello", end='') print (" world")OutputThis will give the output −Hello worldAnother thing you could do is put all the things in an array and call ''.join(array). examplearr = ["Hello", "world"] print(' '.join(arr))OutputThis will give the output −Hello world

Read More

Bootstrap complex form layout for combined vertical/inline fields with HTML

karthikeya Boyini
karthikeya Boyini
Updated on 04-Mar-2020 341 Views

Bootstrap form for combined vertical/ inline fields − Left side Right side longer forms shorter forms shorter forms shorter forms shorter forms Right

Read More

How to capture file not found exception in Java?

karthikeya Boyini
karthikeya Boyini
Updated on 20-Feb-2020 441 Views

While using FileInputStream, FileOutputStream, and RandomAccessFile classes, we need to pass the path of the file to their constructors. In case of a file in the specified path does not exist a FileNotFoundException is raised.Examplepublic class Sample { public static void main(String args[]) throws Exception { File file = new File("myFile"); FileInputStream fis = new FileInputStream(file); System.out.println("Hello"); } }OutputException in thread "main" java.io.FileNotFoundException: myFile (The system cannot find the file specified) ...

Read More

How to access the private methods of a class from outside of the class in Java?

karthikeya Boyini
karthikeya Boyini
Updated on 18-Feb-2020 7K+ Views

You can access the private methods of a class using java reflection package.Step1 − Instantiate the Method class of the java.lang.reflect package by passing the method name of the method which is declared private.Step2 − Set the method accessible by passing value true to the setAccessible() method.Step3 − Finally, invoke the method using the invoke() method.Exampleimport java.lang.reflect.Method; public class DemoTest {    private void sampleMethod() {       System.out.println("hello");    } } public class SampleTest {    public static void main(String args[]) throws Exception {       Class c = Class.forName("DemoTest");       Object obj = c.newInstance(); ...

Read More

How do we initialize a variable in C++?

karthikeya Boyini
karthikeya Boyini
Updated on 11-Feb-2020 265 Views

You can initialize a variable using the assignment operator or use its constructor when initializing it. For example,int i = 0; MyClass instance(1, "Hello");It will be automatically initialized ifIt's a class/struct instance in which the default constructor initializes all primitive types; like MyClass instance; You use array initializer syntax, e.g. int a[10] = {} (all zeroed) or int a[10] = {1,2}; (all zeroed except the first two items: a[0] == 1 and a[1] == 2) It is a global/extern variable It is defined static

Read More

How to build a java web application using SAP platform and HANA database?

karthikeya Boyini
karthikeya Boyini
Updated on 11-Feb-2020 515 Views

You would require to change the connection.properties file of your local Tomcat Server (Server > Java Web Tomcat 8 Server-config/config_master/connection_data), to point to the HANA database.Here are the usual parameters that need to be configured for HANA databasejavax.persistence.jdbc.driver=com.sap.db.jdbc.Driver javax.persistence.jdbc.url=jdbc:sap://:/?reconnect=true&autocommit=false javax.persistence.jdbc.user=db-user javax.persistence.jdbc.password=db-pass eclipselink.target-database=HANA

Read More

What MySQL returns, if the length of the original string is greater than the length specified as an argument in LPAD() or RPAD() functions?

karthikeya Boyini
karthikeya Boyini
Updated on 07-Feb-2020 164 Views

In this case, MySQL will not pad anything and truncate the characters from the original string up to the value of length provided as the argument in LPAD() or RPAD() functions.Examplemysql> Select LPAD('ABCD',3,'*'); +--------------------+ | LPAD('ABCD',3,'*') | +--------------------+ | ABC                | +--------------------+ 1 row in set (0.00 sec) mysql> Select RPAD('ABCD',3,'*'); +--------------------+ | RPAD('ABCD',3,'*') | +--------------------+ | ABC                | +--------------------+ 1 row in set (0.00 sec)We can observe from the above example that both the functions do not pad ‘*’ and truncate the original string up to the length specified i.e. 3 as the argument.

Read More

What is the use of MySQL BINARY keyword while performing string comparison?

karthikeya Boyini
karthikeya Boyini
Updated on 04-Feb-2020 1K+ Views

When MySQL performs string comparison then it is not case-sensitive but with the help of BINARY keyword, MySQL can perform case-sensitive string comparison. It is because BINARY keyword instructs MySQL to compare the characters in the string using their underlying ASCII values rather than just their letters. It can be illustrated with the following example from table ‘Student_info’ having the following data −mysql> Select * from student_info; +------+---------+------------+------------+ | id   | Name    | Address    | Subject    | +------+---------+------------+------------+ | 101  | YashPal | Amritsar   | History    | | 105  | Gaurav  | Chandigarh | ...

Read More
Showing 1021–1030 of 1,421 articles
« Prev 1 101 102 103 104 105 143 Next »
Advertisements