Found 34471 Articles for Programming

How to zip a folder recursively using Python?

Rajendra Dharmkar
Updated on 22-Aug-2023 10:19:52

5K+ Views

It is known that file compression is a routine task in software development and data management in Python. The act of zipping folders recursively is a valuable skill that allows you to compress not only the top-level folder but also all its subdirectories and files; this results in creating a well-organized and space-efficient archive. Python, with its versatility and extensive standard library, makes available multiple approaches to achieve this task effectively. In this comprehensive and exhaustive article, we will explore various methods of how to zip a folder recursively using Python. We have provided step-by-step explanations and code examples to ... Read More

What is binding in Java?

Lakshmi Srinivas
Updated on 30-Jul-2019 22:30:20

5K+ Views

Association of method call with the method body is known as binding in Java. There are two kinds of binding. Static binding In static binding the method call is bonded with the method body at compile time. This is also known as early binding. This is done using static, private and, final methods. Example class Super{ public static void sample(){ System.out.println("This is the method of super class"); } } Public class Sub extends Super{ Public static void sample(){ ... Read More

How to install a Python package into a different directory using pip?

Rajendra Dharmkar
Updated on 11-Sep-2023 17:10:58

7K+ Views

In Python, there is a vast ecosystem of libraries and packages, and it provides developers with a multitude of tools to build powerful applications. For example, the "pip" package manager simplifies the process of installing Python packages from the Python Package Index (PyPI) into the default system−wide site−packages directory. However, in some cases, you might want to install packages into a different directory to maintain better control over dependencies and avoid potential conflicts. In this detailed article, we will explore various methods to install a Python package into a different directory using pip. We will provide step-by-step explanations and code ... Read More

How many ways can get the instance of a Class class in Java?

Monica Mona
Updated on 18-Feb-2020 09:59:52

437 Views

You can create an object of the class named Class in two ways −Using new keyword as −Class obj = new Class();Using the forName() method of the class named Class.Class obj = Class.forName("DemoTest");

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

karthikeya Boyini
Updated on 18-Feb-2020 10:00:48

5K+ 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

What is a method in Java that ends in a semicolon and has no method body?

Sharon Christine
Updated on 30-Jul-2019 22:30:20

609 Views

An abstract method is the one which has no definition and declared abstract. In short, an abstract method contains only method signature without body. To use this method, you need to inherit this method by extending the class and provide the method definition. Example public abstract class Employee{ private String name; private String address; private int number; public abstract double computePay(); }

What is the difference between a Java method and a native method?

Swarali Sree
Updated on 30-Jul-2019 22:30:20

411 Views

A native method is the one whose method implementation is done in other languages like c++ and Java. These programs are linked to Java using JNI or JNA interfaces. The difference between normal method and native method is That the native method declaration contains native keyword and, the implementation of the method will be other programming language. Example Tester.java public class Tester { public native int getValue(int i); public static void main(String[] args) { System.loadLibrary("Tester"); System.out.println(new Tester().getValue(2)); ... Read More

What are native methods in Java and where are they used?

Samual Sam
Updated on 30-Jul-2019 22:30:20

1K+ Views

A native method in Java is a method whose implementation is written in other languages such as c and c++. The ‘native’ keyword is used before a method to indicate that it is implemented in other language.

How to extract a part of the file path (a directory) in Python?

Rajendra Dharmkar
Updated on 22-Aug-2023 11:34:40

2K+ Views

When using file operations and directory structures, working with file paths is a typical task in Python programming. You may occasionally need to strip off particular parts of a file path, such a directory name, in order to analyze or alter it independently. Python offers a number of methods to carry out this work quickly and effectively. This extensive article will examine various techniques for extracting a directory in Python from a file path. We will walk you through the procedure with step-by-step explanations and code samples. You may divide a file path into several parts, get the parent directory, ... Read More

When to use vararg methods in Java?

Sai Subramanyam
Updated on 30-Jul-2019 22:30:20

127 Views

Whenever, you want to pass different number of arguments each time you call a method you should use vararg methods. This example creates sumvarargs() method which takes variable no of int numbers as an argument and returns the sum of these arguments as an output. Example Live Demo public class Main { static int sumvarargs(int... intArrays) { int sum, i; sum = 0; for(i = 0; i< intArrays.length; i++) { ... Read More

Advertisements