Found 34475 Articles for Programming

How do I find the location of my Python site-packages directory?

Rajendra Dharmkar
Updated on 22-Aug-2023 11:26:10

2K+ Views

When it comes to Python development, one essential aspect is knowing how to locate the Python "site-packages" directory. This directory holds a plethora of third-party libraries and packages that enhance Python's capabilities and streamline the development process. Whether you are an experienced developer or just starting, understanding the precise location of the "site-packages" directory empowers you to effectively manage installed packages and enables manual interaction with them. In this comprehensive article, we will explore a variety of methods to pinpoint the location of the "site-packages" directory on different operating systems. From utilizing the versatile "sys" library to leveraging the comprehensive ... Read More

Are the private variables and private methods of a parent class inherited by the child class in Java?

varma
Updated on 30-Jul-2019 22:30:20

710 Views

No, a child class can’t inherit private members of the parent class, it can inherit only protected, default, and public members of it. If you try it gives you a compile time error as: − Example class Super{ private int data = 30; public void display(){ System.out.println("Hello this is the method of the super class"); } } public class Sub extends Super{ public void greet(){ System.out.println("Hello this is the method of the sub class"); ... Read More

What are Java parent and child classes in Java?

usharani
Updated on 16-Jun-2020 08:47:34

14K+ Views

Java supports inheritance, an OOPs concept where one class acquires the members (methods and fields) of another.You can inherit the members of one class from another, use the extends keyword as:class A extends B{}The class which inherits the properties of other is known as child class (derived class, sub class) and the class whose properties are inherited is known as parent class (base class, superclass class).Following is an example which demonstrates inheritance. Here, we have two classes namely Sample and MyClass. Where Sample is the parent class and the class named MyClass is the child class.ExampleLive Democlass Sample{    public ... Read More

What are static members of a Java class?

varun
Updated on 30-Jul-2019 22:30:20

22K+ Views

In Java, static members are those which belongs to the class and you can access these members without instantiating the class. The static keyword can be used with methods, fields, classes (inner/nested), blocks. Static Methods − You can create a static method by using the keyword static. Static methods can access only static fields, methods. To access static methods there is no need to instantiate the class, you can do it just using the class name as − Example Live Demo public class MyClass { public static void sample(){ ... Read More

How to declare, define and call a method in Java?

Prabhas
Updated on 30-Jul-2019 22:30:20

2K+ Views

Following is the syntax to declare a method in Java. Syntax modifier return_type method_name(parameters_list){ //method body } Where, modifier − It defines the access type of the method and it is optional to use. return_type − Method may return a value. method_name − This is the method name. The method signature consists of the method name and the parameter list. parameters_list − The list of parameters, it is the type, order, and a number of parameters of a method. These are optional, method may contain zero parameters. method body − The method body defines ... Read More

How to delete a Python directory effectively?

Rajendra Dharmkar
Updated on 11-Sep-2023 16:50:33

457 Views

As a Python programmer, you might have often encountered situations where you need to delete directories, be it for cleaning up temporary files, organizing data, or managing project resources. However, deleting a directory in Python is not as straightforward or simple as removing a single file. It requires careful consideration of various factors to ensure a safe and efficient deletion process. In this ongoing article, we will explore different methods to delete a Python directory effectively. We will provide step−by−step explanations and code examples to help you through the process. We will cover essential topics such as handling errors, dealing ... Read More

What is the difference between simple name, canonical name and class name in a Java class?

vanithasree
Updated on 30-Jul-2019 22:30:20

2K+ Views

Canonical name of a Java class is the name of the class along with the package. For example, the canonical name of the class File is java.io.File. You can also get the canonical name of a particular class using Java method. The class named Class provides a method getCanonicalName(), this method returns canonical name of the current class. Example Live Demo import java.lang.*; public class ClassDemo { public static void main(String[] args) { ClassDemo c = new ClassDemo(); Class cls = c.getClass(); ... Read More

How to access the members of a class from another class in Java?

radhakrishna
Updated on 30-Jul-2019 22:30:20

11K+ Views

To access the members of a class from other class. First of all, import the class. Create an object of that class. Using this object access, the members of that class. Suppose there is a class in a package called myPackage with a method named display() package myPackage; public class Sample { public void display() { System.out.println("Hello"); } } You can access it as. import myPackage; public class MyClass { public static void main(String args[]) { Sample s = new Sample(); s.done(); } } Output hello

Why do Java array declarations use curly brackets?

Ankitha Reddy
Updated on 30-Jul-2019 22:30:20

492 Views

Curly brackets usually denote sets and ensembles while parenthesis usually in most Algol-based programming languages curly braces are used to declare arrays.

How to declare a class in Java?

mkotla
Updated on 30-Jul-2019 22:30:20

12K+ Views

Following is the syntax to declare a class. class className { //Body of the class } You can declare a class by writing the name of the next to the class keyword, followed by the flower braces. Within these, you need to define the body (contents) of the class i.e. fields and methods.To make the class accessible to all (classes) you need to make it public. public class MyClass { //contents of the class (fields and methods) }

Advertisements