Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Programming Articles - Page 2048 of 3363
3K+ Views
Yes, we can have private methods or private static methods in an interface in Java 9. We can use these methods to remove the code redundancy. Private methods can be useful or accessible only within that interface only. We can't access or inherit private methods from one interface to another interface or class.Syntaxinterface { private static void methodName() { // some statements } private void methodName() { // some statements } }Exampleinterface Java9Interface { public abstract void method1(); public default void method2() { method4(); method5(); ... Read More
202 Views
JShell is the first REPL tool introduced in Java 9. We can able to execute simple snippets in a command-line prompt by using JShell tool. We can start a JShell session by typing "jshell" command, stop the session by typing "/exit" command, and search for particular command by using "/help" command.The "/reload" command can be used to re-execute all existing snippets in JShell. We can also remove all prior code from a JShell session by using the "/reset" command.In the below code snippet, we have created a set of snippets.jshell> 2+10 $1 ==> 12 jshell> String s = "Tutorialspoint" s ... Read More
2K+ Views
Java 9 version has introduced new enhancements and added new features. It includes JShell, Http2Client, Java Platform Module System (JPMS), Multi-release jar files, Stack Walking API, Private methods in an interface, Process API updates, Collection API updates, Stream API improvements, and etc.Below are the few differences between Java 8 and Java 9In Java 8 and earlier versions, the top-level component is the package. It places a set of related types (classes, interfaces, enums, and etc) into a group, and also contains a set of resources whereas Java 9 introduces a new component: module, which can be used to place a ... Read More
256 Views
IIn this tutorial, we will be discussing a program to understand how to delete elements in the C++ STL list.For this, we will be using the pop_back() and pop_front() function to delete the element from last and the front respectively.Example Live Demo#include #include using namespace std; int main(){ listlist1={10,15,20,25,30,35}; cout
213 Views
In this tutorial, we will be discussing a program to understand how to initiate a multidimensional array in C/C++.While declaring a multidimensional array, the value of the leftmost dimension can be left empty, but all other dimensions must be provided.Example Live Demo#include int main(){ int a[][2] = {{1,2},{3,4}}; printf("%lu", sizeof(a)); getchar(); return 0; }Output16
135 Views
In this tutorial, we will be discussing a program to understand extended integral types in C/C++.The data types in C are very loosely defined. Their range values changes on the basis of the compiler being 32 or 64 bit. To specify the compiler range you want to use in your program we use intN_t.Example Live Demo#include using namespace std; int main(){ uint8_t i; //mentioning the bit to be 8 i = 0; cout
1K+ Views
In this tutorial, we will be discussing a program to understand File Handling through C++ classes. What's File Handling? File handling is an important concept in programming, which allows a program to read from and write to files. C++ has built-in classes and functions for file handling, which is done using file stream classes that are part of the library. The most common file stream classes in C++ are ofstream, ifstream, fstream. ofstream: This class is used for output file streams, where it allows the user to write data to files. ... Read More
6K+ Views
In this tutorial, we will be discussing a program to draw a line in C++ graphics.To implement different shapes and sizes, animations, graphics.h library is used in C++.Example#include int main(){ int gd = DETECT, gm; initgraph(&gd, &gm, ""); line(150, 150, 450, 150); line(150, 200, 450, 200); line(150, 250, 450, 250); getch(); closegraph(); return 0; }Output
225 Views
In this tutorial, we will be discussing a program to understand if the C++ compiler creates a default constructor when we write our own.Generally, the C++ compiler uses the default constructor when no one is defined, but always uses the one defined by the user if any.Example Live Demo#include using namespace std; class myInteger{ private: int value; //other functions in class }; int main(){ myInteger I1; getchar(); return 0; }OutputCompiles successfullyExample#include using namespace std; class myInteger{ private: int value; public: myInteger(int v) //user-defined constructor { value = ... Read More
178 Views
In this tutorial, we will be discussing a program to understand delete() and free() functions in C++.Both of these functions are primarily used for the same purpose i.e freeing up unused memory. The delete() operator is for the ones allocated using new() and free() for the ones allocated using malloc().Example#include #include int main(){ int x; int *ptr1 = &x; int *ptr2 = (int *)malloc(sizeof(int)); int *ptr3 = new int; int *ptr4 = NULL; //incorrect usage of delete delete ptr1; delete ptr2; //correct usage of delete delete ptr3; delete ptr4; getchar(); return 0; }